LION.utils.environment

The record of the environment a model was saved in.

environment_record() is written by LIONmodel.save in every model file, as its environment (a LIONParameter, saved as plain JSON):

  • lion: LION’s version; for a git checkout its commit, the LION files with uncommitted changes (files git tracks that changed, and untracked files that were imported), a diff_sha256 of those changes, and whether the commit is pushed (in a remote branch git knows of); for an installed LION, its distribution version;

  • python, and packages: the versions of the packages that change LION’s numbers (torch, numpy, the CT backends; None if not installed);

  • torch: the CUDA and cuDNN it was built with, and its determinism settings (deterministic_algorithms, cudnn_deterministic, cudnn_benchmark): same-seed GPU runs are only identical with them on;

  • device: the device type the model was on, the GPUs and their driver;

  • platform: the operating system.

Nothing personal is recorded (no hostname, user or paths). A full list of the installed packages belongs to publish(), not to every file.

code_differences(record) says how the running LION code differs from the code a file was saved with (LIONmodel warns on load); publish_problems(record) lists what keeps a result from being published (uncommitted or unpushed LION code).

Functions

code_differences(record[, folder])

How the LION code running now differs from the code record (an environment record) was made with, as a sentence; None if it doesn't (or it can't be told).

code_state([folder])

The state of the code in folder (a package in a git checkout): commit, uncommitted (files changed since it: tracked files, and untracked ones that were imported), diff_sha256 (of those changes; None if there are none) and pushed (the commit is in a remote branch).

environment_record([device])

The environment LION runs in now (see the module docstring); device: the device of the model being saved (default: LION's default device).

is_environment_record(value)

Whether value (a dict or a LIONParameter) is an environment record: it has the record's key.

publish_problems(record)

What keeps a result made in environment record from being published: LION code with uncommitted changes, or a commit that isn't pushed.


LION.utils.environment.code_differences(record, folder=PosixPath('/mhome/damtp/r/ab2860/AItomotools/LION'))[source]

How the LION code running now differs from the code record (an environment record) was made with, as a sentence; None if it doesn’t (or it can’t be told).

LION.utils.environment.code_state(folder=PosixPath('/mhome/damtp/r/ab2860/AItomotools/LION'))[source]

The state of the code in folder (a package in a git checkout): commit, uncommitted (files changed since it: tracked files, and untracked ones that were imported), diff_sha256 (of those changes; None if there are none) and pushed (the commit is in a remote branch). All None if folder is not in a git checkout.

LION.utils.environment.environment_record(device=None)[source]

The environment LION runs in now (see the module docstring); device: the device of the model being saved (default: LION’s default device).

LION.utils.environment.is_environment_record(value)[source]

Whether value (a dict or a LIONParameter) is an environment record: it has the record’s key.

LION.utils.environment.publish_problems(record)[source]

What keeps a result made in environment record from being published: LION code with uncommitted changes, or a commit that isn’t pushed. Empty if nothing.