napistu_torch.utils.environment_info

Functions

create_install_directions(torch_version, ...)

Format environment information as installation directions.

Classes

EnvironmentInfo(*, python_version, ...)

Python environment information for reproducibility.

class napistu_torch.utils.environment_info.EnvironmentInfo(*, python_version: str, python_implementation: str, platform_system: str, platform_release: str, napistu_version: str | None = None, napistu_torch_version: str | None = None, torch_version: str | None = None, torch_geometric_version: str | None = None, pytorch_lightning_version: str | None = None, extra_packages: Dict[str, str]=<factory>)

Bases: BaseModel

Python environment information for reproducibility.

Captures key package versions and Python environment details to help reproduce training environments and debug compatibility issues.

classmethod from_current_env(extra_packages: list[str] | None = None) EnvironmentInfo

Create EnvironmentInfo from the current Python environment.

Captures Python version, platform details, and versions of key packages including napistu, napistu-torch, torch, torch_geometric, and lightning.

Parameters:

extra_packages (Optional[list[str]], optional) – Additional package names to capture versions for, by default None

Returns:

Environment information from current Python environment

Return type:

EnvironmentInfo

Examples

>>> env_info = EnvironmentInfo.from_current_env()
>>> print(env_info.napistu_torch_version)
'0.1.0'
>>> # Capture additional packages
>>> env_info = EnvironmentInfo.from_current_env(
...     extra_packages=['numpy', 'pandas', 'wandb']
... )
>>> print(env_info.extra_packages)
{'numpy': '1.26.0', 'pandas': '2.1.0', 'wandb': '0.16.0'}
get_install_directions() str

Format environment information as installation directions.

Returns a multiline string with suggested installation commands to reproduce the environment.

Returns:

Multiline string with installation directions

Return type:

str

get_summary() Dict[str, str]

Convert to a flat dictionary for display.

Returns:

Flat dictionary with all environment info

Return type:

Dict[str, str]

Examples

>>> env_info = EnvironmentInfo.from_current_env()
>>> summary = env_info.to_summary_dict()
>>> for key, value in summary.items():
...     print(f"{key}: {value}")
_abc_impl = <_abc._abc_data object>
extra_packages: Dict[str, str]
model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

napistu_torch_version: str | None
napistu_version: str | None
platform_release: str
platform_system: str
python_implementation: str
python_version: str
pytorch_lightning_version: str | None
torch_geometric_version: str | None
torch_version: str | None
napistu_torch.utils.environment_info.create_install_directions(torch_version: str, napistu_version: str, napistu_torch_version: str) str

Format environment information as installation directions.

Returns a multiline string with suggested installation commands to reproduce the environment.

Parameters:
  • torch_version (str) – PyTorch version

  • napistu_version (str) – Napistu version

  • napistu_torch_version (str) – Napistu-Torch version

Returns:

Multiline string with installation directions

Return type:

str