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

filename not saved in YAML configuration file #80

Closed
ThibHlln opened this issue Mar 26, 2022 · 1 comment
Closed

filename not saved in YAML configuration file #80

ThibHlln opened this issue Mar 26, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ThibHlln
Copy link
Member

ThibHlln commented Mar 26, 2022

There seems to be a bug in unifhy when the files contained in the unifhy.DataSet are small enough so that they can fit in memory. This seems to be linked to the documented behaviour of cf.Field.get_filenames:

The file names in normalised, absolute form. If all of the data are in memory then an empty set is returned.

This results in the filenames attribute of a given unifhy.Variable to be an empty set. Ultimately leading to saving an empty sequence of filenames in the YAML file, so that a to_yaml > from_yaml workflow fails.

It would be good to check with cf-python whether there is another functionality that keeps track of filenames, or if it makes sense for their package to offer such functionality. If not, it will be up to unifhy to keep track of them.

@ThibHlln
Copy link
Member Author

ThibHlln commented Mar 31, 2022

As per David's suggestion (NCAS-CMS/cf-python#365), it makes more sense for unifhy to manually store the filenames right after the call to cf.read.

And it turned out, it was already the case:

unifhy/unifhy/data.py

Lines 172 to 178 in c4e235c

def _get_dict_variables_from_file(files, name_mapping, select):
variables = {}
for field in cf.read(
files, aggregate={'relaxed_identities': True}, select=select
):
filenames = field.get_filenames()

But then, Component is manipulating the fields contained in DataSet in such a way that cf will drop the filenames along the way. In a couple of places later in the workflow, filenames are retrieved from the field directly (i.e. using Field.get_filenames() method) rather than from the variable (i.e. using Variable.filenames attribute):

filenames = dataset[data_name].field.get_filenames()

filenames = field.get_filenames()

This needs to be fixed by using the Variable attribute instead of the Field method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant