Skip to content

[1699] Allow anemoi-datasets config to be passed to the reader#1958

Draft
cristianlussana wants to merge 4 commits intoecmwf:developfrom
metno:cristianl/PR1699_anemoi_config_join
Draft

[1699] Allow anemoi-datasets config to be passed to the reader#1958
cristianlussana wants to merge 4 commits intoecmwf:developfrom
metno:cristianl/PR1699_anemoi_config_join

Conversation

@cristianlussana
Copy link

Description

The Anemoi datasets reader only supports passing in a filename. In many cases it is more convenient to pass in a config dictionary. This allows multiple datasets to be joined and allows operations to be performed on the dataset.

Changes

multi_stream_data_sampler.py: Modified the way filename is defined

Issue Number

Closes #1699

Is this PR a draft? Mark it as draft.

Checklist before asking for review

  • I have performed a self-review of my code
  • My changes comply with basic sanity checks:
    • I have fixed formatting issues with ./scripts/actions.sh lint
    • I have run unit tests with ./scripts/actions.sh unit-test
    • I have documented my code and I have updated the docstrings.
    • I have added unit tests, if relevant
  • [ x] I have tried my changes with data and code:
    • I have run the integration tests with ./scripts/actions.sh integration-test
    • (bigger changes) I have run a full training and I have written in the comment the run_id(s): launch-slurm.py --time 60
    • (bigger changes and experiments) I have shared a hegdedoc in the github issue with all the configurations and runs for this experiments
  • I have informed and aligned with people impacted by my change:
    • for config changes: the MatterMost channels and/or a design doc
    • for changes of dependencies: the MatterMost software development channel

##
filename = stream_info.get("filenames")
if type(filename) is omegaconf.dictconfig.DictConfig:
# Convert OmegaConf DictConfig to dict
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test here immediately for filename['join'] and generate an error if it does not exist.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also generate an error here if type is not anemoi

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Then, for the moment, we implement only the possibility to join anemoi datasets and we leave other operations for later implementations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that at l169 we do for fname in stream_info["filenames"]: this loop currently does nothing useful (fname is not used) but maybe I don't get it correctly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that at l169 we do for fname in stream_info["filenames"]: this loop currently does nothing useful (fname is not used) but maybe I don't get it correctly

I just compared to develop and there the iteration over the elements in filenames does make sense:

for fname in stream_info["filenames"]:
. Can you have another look so that the else branch (i.e. filenames is not a dict) is equivalent to current develop.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Now I have aligned the else branch to the current develop

if not any(filename.exists() for filename in filenames): # see above
##
filename = stream_info.get("filenames")
if type(filename) is omegaconf.dictconfig.DictConfig:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two branches of the if-statement should go to separate functions to not blow up the constructor here even further.

# list of sources for current stream
self.streams_datasets[stream_info["name"]] = []

for fname in stream_info["filenames"]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the changes in l167 ff are correct because the list case is handled here and the check for dict should be at the same level.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just opened #1960 to move 148-165 above 147 since it doesn't belong here--sorry if this confused you

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Fine with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Allow anemoi-datasets config to be passed to the reader

2 participants