Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing 'name' attribute in 'GCSFile' object when accessing PDF files #617

Open
bhavan-kaya opened this issue Mar 20, 2024 · 1 comment
Open

Comments

@bhavan-kaya
Copy link

bhavan-kaya commented Mar 20, 2024

Description:
In the context of using gcsfs with llama-index for reading files from a GCP bucket, an error occurs for PDF files indicating that the 'GCSFile' object has no attribute 'name'. This issue does not occur when accessing DOCX files. It suggests that there may be an inconsistency or a bug in how gcsfs handles file metadata, specifically for PDF files.

import google.auth
from llama_index.core import SimpleDirectoryReader
from gcsfs import GCSFileSystem
from fs_gcsfs import GCSFS

def __load_gcp_bucket(bucket_path: str):
    credentials, project_id = google.auth.default(
        scopes=["https://www.googleapis.com/auth/devstorage.read_only"]
    )

    gcp_fs = GCSFileSystem(project=project_id, token=credentials)

    reader = SimpleDirectoryReader(
        input_dir=bucket_path,
        fs=gcp_fs,
    )

    documents = reader.load_data()
    return documents

documents = __load_gcp_bucket("<bucket-path>/")
print(documents)

Version:

  • gcsfs: (specify the version you're using, e.g., 2023.6.0)

Steps to Reproduce:

  1. Use GCSFileSystem from gcsfs to access files in a GCP bucket.
  2. Attempt to read metadata from both .pdf and .docx files.
  3. Compare the behavior and output to identify the absence of the name attribute in the case of PDF files.

Relevant Logs/Tracebacks:

Failed to load file <GCS bucket path>/file.pdf with error: 'GCSFile' object has no attribute 'name'. Skipping...
@martindurant
Copy link
Member

Please show the full traceback, so we can see what llama_index is trying to do. You may also want to cross-post on their tracker. No GCSFile has a .name, but they do have a .path .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants