Skip to content

Dataset loaded from S3 file returns _filename as "None" (str) #199

@valeriupredoi

Description

@valeriupredoi

We need the filename when working with already loaded pyfive datasets, afraid that returns as None (str) in many (if not all) cases. Here is an MRE:

import os

import pyfive
import s3fs


def get_filename_real_s3():
    """Extract _filename from a real S3 file."""
    storage_options = {
        "anon": True,
        "client_kwargs": {"endpoint_url": "https://uor-aces-o.s3-ext.jc.rl.ac.uk"},
    }
    fs = s3fs.S3FileSystem(**storage_options)
    uri = os.path.join("esmvaltool-zarr", "CMIP6-test.nc")
    s3file = fs.open(uri, "rb")
    ds = pyfive.File(s3file)["tas"]
    print(ds.id._filename)
    print(ds.id._filename == "esmvaltool-zarr/CMIP6-test.nc")

get_filename_real_s3()

Fix pushed and tested in #197

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions