fsspec / fsspec/gcsfs

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

Open
#617 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
398
Forks
181
Avg merge
2d 10h
Merged PRs (30d)
36

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the error with GCSFileSystem against both PDF and DOCX objects, then inspect how GCSFile exposes metadata when used by SimpleDirectoryReader. Compare the two paths and confirm that the relevant file identity is available consistently for PDF loading, with a regression check covering the reported traceback.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, python
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.