provenance

Collect information about the current environment, like:

  • The Python version

  • The versions of the modules which are currently loaded

  • The git information for the modules which are currently loaded from a git repository

anemoi.utils.provenance.editable_installs() dict[str, Path]

Return a dictionary of editable installs.

The check relies on how editable installs are handled based on PEP610. A <path-to-venv>/lib/site-packages/<package>.dist-info/direct_url.json file should be present.

Returns:

A dictionary mapping package names to their source directories for editable installs.

Return type:

dict[str, Path]

anemoi.utils.provenance.is_editable_install(init_path: str | Path) bool

Determine if the given path corresponds to an editable install.

anemoi.utils.provenance.lookup_git_repo(path: str) Any | None

Lookup the git repository for a given path.

Parameters:

path (str) – The path to lookup.

Returns:

The git repository if found, otherwise None.

Return type:

Repo, optional

anemoi.utils.provenance.package_distributions() dict[str, list[str]]

Get the package distributions.

Returns:

The package distributions.

Return type:

dict

anemoi.utils.provenance.import_name_to_distribution_name(packages: list[str]) dict[str, str]

Convert import names to distribution names.

Parameters:

packages (list of str) – The list of import names.

Returns:

The dictionary mapping import names to distribution names.

Return type:

dict

anemoi.utils.provenance.module_versions(full: bool) tuple[dict[str, Any], dict[str, Any]]

Collect version information for all loaded modules and their git information.

Parameters:

full (bool) – Whether to collect full information.

Returns:

The version information and the git information.

Return type:

tuple of dict and dict

anemoi.utils.provenance.git_check(*args: Any) dict[str, Any]

Return the git information for the given arguments.

Arguments can be:
  • an empty list, in that case all loaded modules are checked

  • a module name

  • a module object

  • an object or a class

  • a path to a directory

Parameters:

args (list) – The list of arguments to check

Returns:

An object with the git information for the given arguments.

>>> {
        "anemoi.utils": {
            "sha1": "c999d83ae283bcbb99f68d92c42d24315922129f",
            "remotes": [
                "git@github.com:ecmwf/anemoi-utils.git"
            ],
            "modified_files": [
                "anemoi/utils/checkpoints.py"
            ],
            "untracked_files": []
        }
    }

Return type:

dict

anemoi.utils.provenance.platform_info() dict[str, Any]

Get the platform information.

Returns:

The platform information.

Return type:

dict

anemoi.utils.provenance.gpu_info() str | list[dict[str, Any]]

Get the GPU information.

Returns:

The GPU information or an error message.

Return type:

str or list of dict

anemoi.utils.provenance.path_md5(path: str) str

Calculate the MD5 hash of a file.

Parameters:

path (str) – The path to the file.

Returns:

The MD5 hash of the file.

Return type:

str

anemoi.utils.provenance.assets_info(paths: list[str]) dict[str, Any]

Get information about the given assets.

Parameters:

paths (list of str) – The list of paths to the assets.

Returns:

The information about the assets.

Return type:

dict

anemoi.utils.provenance.gather_provenance_info(assets: list[str] = [], full: bool = False) dict[str, Any]

Gather information about the current environment.

Parameters:
  • assets (list, optional) – A list of file paths for which to collect the MD5 sum, the size and time attributes, by default []

  • full (bool, optional) – If true, will also collect various paths, by default False

Returns:

A dictionary with the collected information

Return type:

dict