Skip to content

New "original filenames" methods #215

Closed

Description

@davidhassell

The conversation at NCAS-CMS/cf-python#365 discussed how to record the names of files the contained some or all of the data at instantiation time - typically (but not necessarily) from a read call.

I propose a new suite of original_filenames methods that allow us to define, report, and edit these "original" files - those that contained some or all of the data at instantiation time - and are independent of the get_filenames methods. get_filenames reports on any files that are used by Data objects at the time of asking, which might reported different (typically fewer) files than were being used at the time of data instantiation.

It is also the case that the daskification of the cf-python library confuses functionality of the get_filenames methods - due to the new lazy execution paradigm, the notion of files in use at the time of asking is a little fuzzy.

I propose along the lines of:

>>> f = cfdm.read("parent_file.nc")[0]
>>> f.original_filenames()
{"parent_file.nc"}

>>> f = cfdm.read("parent_file.nc", external="external_file.nc")[0]
>>> f.original_filenames()
{"parent_file.nc", "external_file.nc"}
>>> f.original_filenames(update="file.nc")
>>> f.original_filenames()
{"parent_file.nc", "external_file.nc", "file.nc"}
>>> f.original_filenames(clear=True)
{"parent_file.nc", "external_file.nc", "file.nc"}
>>> f.original_filenames()
set()

You might want to edit the original file names if you are creating constructs ab initio (without cfdm.read, which will set them for you automatically), or if you are creating a Field (or Data or any other construct) that is some combination of other - in this case you might want to store the superset of original files.

Many thanks to @ThibHlln for first raising this over at the cf-python issue mentioned above. This functionally will be inherited by cf-python, so will be available there, too!

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions