checkpoint

anemoi.inference.checkpoint.get_multi_dataset_metadata(metadata: dict, supporting_arrays: dict, base_class=<class 'anemoi.inference.metadata.Metadata'>) dict[str, SingleDatasetMetadata | MultiDatasetMetadata]

Metadata objects for all datasets in the raw metadata, as a mapping from dataset name to Metadata object. For legacy checkpoints, the dataset name defaults to data

class anemoi.inference.checkpoint.Checkpoint(source: str | ~anemoi.inference.metadata.Metadata | dict[~typing.Literal['huggingface'], str | dict], *, metadata_base: type[~anemoi.inference.metadata.Metadata] = <class 'anemoi.inference.metadata.Metadata'>, patch_metadata: dict[str, ~typing.Any] | None = None)

Bases: object

Represents an inference checkpoint.

property path: str

Get the path to the checkpoint.

property multi_dataset: bool

Check if the checkpoint is a multi-dataset checkpoint.

property multi_dataset_metadata: dict[str, SingleDatasetMetadata | MultiDatasetMetadata]

Metadata for all datasets in the checkpoint, as a mapping from dataset name to Metadata object. For legacy checkpoints, the dataset name defaults to data

property timestep: Any

Get the timestep.

property lagged: list[timedelta]

Return the list of steps for the multi_step_input fields.

property multi_step_input: int

Get the multi-step input.

property multi_step_output: int

Get the multi-step output.

property input_explicit_times: Any

Get the input explicit times from metadata.

property target_explicit_times: Any

Get the target explicit times.

property data_frequency: Any

Get the data frequency.

property precision: Any

Get the precision.

property sources: list[SourceCheckpoint]

Get the sources.

report_error() None

Report an error.

validate_environment(*, all_packages: bool = False, on_difference: Literal['warn', 'error', 'ignore', 'return'] = 'warn', exempt_packages: list[str] | None = None) bool | str

Validate the environment.

Parameters:
  • all_packages (bool, optional) – Check all packages in the environment (True) or just anemoi’s (False), by default False.

  • on_difference (Literal['warn', 'error', 'ignore', 'return'], optional) – What to do on difference, by default “warn”

  • exempt_packages (list[str], optional) – List of packages to exempt from the check, by default EXEMPT_PACKAGES

Returns:

boolean if on_difference is not ‘return’, otherwise formatted text of the differences True if environment is valid, False otherwise

Return type:

Union[bool, str]

provenance_training() Any

Get the provenance of the training.

Returns:

The provenance of the training.

Return type:

Any

update_metadata_from_zarr() tuple[dict[str, Any], dict[str, Any]]

Get new metadata and supporting array dictionaries from the original training dataset. Useful if the training dataset metadata has been patched/updated. Updates the internal _raw_metadata and returns a new (metadata, supporting_arrays).

class anemoi.inference.checkpoint.SourceCheckpoint(owner: Checkpoint, metadata: Any)

Bases: Checkpoint

A checkpoint that represents a source.