Skip to navigation

nemo_gym.artifacts.exporters.metrics

View as Markdown

Module Contents

Functions

NameDescription
_canonical_mlflow_keyThe backend key shared by health preflight and MLflow delivery, without importing the optional SDK.
_elide_keyCut an over-long name in the middle, keeping both ends.
_normalize_key_pathNeutralize only the path segments MLflow rejects, leaving the rest of the name intact.
flatten_aggregate_metricsThe scalar metrics a tracking backend gets from per-agent aggregate-metrics entries.
health_source_artifactsBind derived health to the same saved inputs, Store selection and underlying health report.

Data

_ELISION_MARKER

_INVALID_KEY_CHARS

_LEADING_DOTS

_MLFLOW_KEY_LENGTH_LIMIT

_PRIMITIVE_TYPES

API

nemo_gym.artifacts.exporters.metrics._canonical_mlflow_key(
key: str,
limit: int = _MLFLOW_KEY_LENGTH_LIMIT
) -> str | None

The backend key shared by health preflight and MLflow delivery, without importing the optional SDK.

nemo_gym.artifacts.exporters.metrics._elide_key(
key: str,
limit: int = _MLFLOW_KEY_LENGTH_LIMIT
) -> str

Cut an over-long name in the middle, keeping both ends.

Gym names carry their identity at the edges — benchmark and agent in the prefix, the statistic in the suffix (gpqa.../simple_agent/mean/reward) — so the middle is what can be spared.

nemo_gym.artifacts.exporters.metrics._normalize_key_path(
key: str
) -> str

Neutralize only the path segments MLflow rejects, leaving the rest of the name intact.

MLflow requires an already-normalized relative path, so it rejects empty segments (from leading, doubled or trailing slashes) and the traversal forms . and ...

nemo_gym.artifacts.exporters.metrics.flatten_aggregate_metrics(
agent_entries: typing.Iterable[dict[str, typing.Any]],
source_artifacts: dict[str, typing.Any] | None = None
) -> dict[str, typing.Any]

The scalar metrics a tracking backend gets from per-agent aggregate-metrics entries.

Live runs and post-run export both build their metrics here, so a run looks the same in the backend either way: <agent>/<metric> and key_metrics/<agent>/<metric>, primitive values only.

nemo_gym.artifacts.exporters.metrics.health_source_artifacts(
artifacts,
version: dict[str, typing.Any]
) -> dict[str, typing.Any]

Bind derived health to the same saved inputs, Store selection and underlying health report.

nemo_gym.artifacts.exporters.metrics._ELISION_MARKER = '___'
nemo_gym.artifacts.exporters.metrics._INVALID_KEY_CHARS = re.compile('[^/\\w.\\- :]')
nemo_gym.artifacts.exporters.metrics._LEADING_DOTS = re.compile('^\\.+')
nemo_gym.artifacts.exporters.metrics._MLFLOW_KEY_LENGTH_LIMIT = 250
nemo_gym.artifacts.exporters.metrics._PRIMITIVE_TYPES = (bool, int, float, str, type(None))