rgpycrumbs.uma._env

Probe the export interpreter once, then remember the answer.

The key needs the torch and fairchem versions and the device target of the interpreter that runs the exporter. Asking costs a torch import (seconds), which would dominate a cache hit, so the answer is stored under <cache>/.env/. For the running interpreter the memo is keyed by its installed distributions; for another interpreter by its path, and reused while its site-packages directory is unchanged (installing or removing a distribution changes its mtime).

Attributes

Functions

normalize_device(→ str)

cpu, cuda or cuda:N; anything else is refused.

_local_fingerprint(→ str)

Installed distributions of this interpreter, from directory names alone.

_is_local(→ bool)

_memo_path(→ pathlib.Path)

_fresh(→ bool)

probe_env(→ rgpycrumbs.uma._key.ExportEnv)

Return the ExportEnv of python (default: this interpreter).

Module Contents

rgpycrumbs.uma._env._PROBE[source]
rgpycrumbs.uma._env.normalize_device(device: str) → str[source]

cpu, cuda or cuda:N; anything else is refused.

rgpycrumbs.uma._env._local_fingerprint() → str[source]

Installed distributions of this interpreter, from directory names alone.

uv run --script can give one set of packages a new environment path on every run, so for the running interpreter the identity is what is installed (<name>-<version>.dist-info entries on sys.path), not where.

rgpycrumbs.uma._env._is_local(python: str) → bool[source]
rgpycrumbs.uma._env._memo_path(cache_dir: pathlib.Path, python: str, device: str) → pathlib.Path[source]
rgpycrumbs.uma._env._fresh(memo: dict) → bool[source]
rgpycrumbs.uma._env.probe_env(cache_dir: pathlib.Path, *, python: str | None = None, device: str = 'cpu') → rgpycrumbs.uma._key.ExportEnv[source]

Return the ExportEnv of python (default: this interpreter).