Skip to content

Conversation

HCookie
Copy link
Member

@HCookie HCookie commented Sep 30, 2025

Description

For LAM or Nested Grid usage redefining the region or specification of the graph is useful for testing and exploration.
This PR formalises that process within a subcommand to allow easy usage.

It pulls the graph data from the checkpoint to ensure consistency, or allows for a full graph on disk to be used.

Usage

anemoi-inference redefine OLD_CHECKPOINT.ckpt -c -8 30 -22 43 0.1/0.1 --save-graph graph_updated.pt -gr n320

As a contributor to the Anemoi framework, please ensure that your changes include unit tests, updates to any affected dependencies and documentation, and have been tested in a parallel setting (i.e., with multiple GPUs). As a reviewer, you are also responsible for verifying these aspects and requesting changes if they are not adequately addressed. For guidelines about those please refer to https://anemoi.readthedocs.io/en/latest/

By opening this pull request, I affirm that all authors agree to the Contributor License Agreement.


📚 Documentation preview 📚: https://anemoi-inference--336.org.readthedocs.build/en/336/

@HCookie HCookie self-assigned this Sep 30, 2025
@HCookie HCookie added documentation Improvements or additions to documentation enhancement New feature or request ATS Approval needed labels Sep 30, 2025
@github-project-automation github-project-automation bot moved this to To be triaged in Anemoi-dev Sep 30, 2025
@HCookie HCookie moved this from To be triaged to Reviewers needed in Anemoi-dev Sep 30, 2025
@github-actions github-actions bot added the bug Something isn't working label Sep 30, 2025
@HCookie HCookie force-pushed the feat/add_checkpoint_update_cmd branch from 01ae1f7 to db7627b Compare September 30, 2025 08:08
Copy link
Member

@gmertes gmertes left a comment

Choose a reason for hiding this comment

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

Maybe a bit more explicitness in the naming: redefine-graph for the command name, and utils/redefine_graph.py for the utils file?

For a review of the functional implementation maybe @dietervdb-meteo, @frazane and @havardhhaugen would like to have a look?

HCookie and others added 2 commits September 30, 2025 13:11
Co-authored-by: Gert Mertes <13658335+gmertes@users.noreply.github.com>
@HCookie HCookie force-pushed the feat/add_checkpoint_update_cmd branch from 6086dd4 to 71a8f25 Compare September 30, 2025 12:31
Copy link
Contributor

@frazane frazane left a comment

Choose a reason for hiding this comment

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

Thanks @HCookie this is really helpful. Looks good to me already, though I haven't had time to hands-on test. But we can have a look this week.

anemoi-inference redefine_graph path/to/checkpoint --coords 30.0 -10.0 20.0 0.0 0.1/0.1 --global_resolution n320
All examples can optionally save the updated graph and checkpoint using the `--save-graph` and `--output` options.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you chose to make the output optional? Shouldn't it be a mandatory positional argument?

Copy link
Member Author

Choose a reason for hiding this comment

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

For arbitary convenience as it will add a suffix by default and still save it

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable. I would clarify this in the docs.

elif args.coords is not None:
local_lats, local_lons = get_coordinates_from_mars_request(args.coords)
else:
raise ValueError("No valid coordinates found.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't be reached if argparse is working correctly but one more check doesn't hurt.


def check_redefine_imports():
"""Check if required packages are installed."""
required_packages = ["anemoi.datasets", "anemoi.graphs", "anemoi.models"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be useful to add these packages to the optional dependencies in the pyproject.toml, or is it up to the user to install these manually if they want to use this functionality?

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

Labels

ATS Approval needed bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: Reviewers needed

Development

Successfully merging this pull request may close these issues.

5 participants