Skip to content

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

Open

Description

@bhavan-kaya

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...

Activity

  1. martindurant commented on Mar 20, 2024

    @martindurant
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions