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

New "original filenames" methods #215

Closed
davidhassell opened this issue Sep 9, 2022 · 0 comments · Fixed by #216
Closed

New "original filenames" methods #215

davidhassell opened this issue Sep 9, 2022 · 0 comments · Fixed by #216
Labels
enhancement New feature or request
Milestone

Comments

@davidhassell
Copy link
Contributor

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!

@davidhassell davidhassell added the enhancement New feature or request label Sep 9, 2022
@davidhassell davidhassell added this to the Next release milestone Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant