Skip to main content

euler

euler-metric-naming

Make flat ML metric keys self-describing.

PyPI Python versions License: MIT CI


Metric logs are usually flat dictionaries. A key such as loss is easy to write, but it does not say what was measured, where it came from, or how a downstream tool should group it. This package turns that key into a small, validated schema:

loss = 0.089  →  depth.train.loss.final.log_radius = 0.089

It builds metric names, declares the axes inside them, attaches display metadata, and serializes the declaration beside the values. It does not collect, store, or render metrics; it is the shared naming contract between those jobs.

Anatomy of a metric name

depth train loss final log_radius
scope context kind axis stage axis (optional) base metric

Together, depth.train is the namespace. The remaining declared axes make the hierarchy useful for indexing and filtering, while log_radius identifies the measurement itself:

{scope}.{context}.{axes...}.{metric}

Axes are described by position and allowed values. Consumers can therefore decompose a name structurally instead of guessing from substrings.

Where it fits

flowchart LR
    N["euler-metric-naming<br/><b>names + schema</b>"]
    T["euler-train<br/><i>run metrics</i>"]
    E["euler-eval<br/><i>evaluation results</i>"]
    V["euler-view<br/><i>index, group, filter</i>"]
    J["eval.json<br/><i>metricSet envelope</i>"]

    N -->|keys + metric_naming| T
    N -->|axes + descriptions| E
    T --> V
    E --> J
  • euler-train still logs a flat dict[str, float]; the accompanying metric_naming payload tells euler-view how to interpret it.
  • euler-eval, the package's main consumer today, writes the same declarations as a metricSet envelope in each eval.json.
  • euler-metric-naming owns the shared construction, validation, decomposition, and serialization rules so producers do not drift apart.

Install

pip install euler-metric-naming

The core package has no runtime dependencies. Install euler-metric-naming[contract] to additionally warn when a modality is not in the euler-dataset-contract registry.

Quick start: training metrics

Declare the modalities and any pipeline stages once:

from euler_metric_naming import MetricDescription, MetricNamespace

metrics = MetricNamespace(
    producer="euler_train.weather_model",
    producer_version="0.1.0",
    modalities=("depth", "rgb"),
    stages=("prior", "final"),
    descriptions={
        "depth_mae": MetricDescription(
            display_name="Depth MAE",
            is_higher_better=False,
            unit="meters",
        ),
    },
)

Then use the namespace wherever values are logged:

values = {
    metrics.loss("depth", "prior", "log_radius"): 0.152,
    metrics.diag("depth", "final", "depth_mae"): 0.283,
    metrics.loss("depth", metric="total"): 1.234,
    metrics.sys("lr"): 3e-5,
}

# {
#   "depth.train.loss.prior.log_radius": 0.152,
#   "depth.train.diag.final.depth_mae": 0.283,
#   "depth.train.loss.total": 1.234,
#   "sys.train.lr": 3e-5,
# }

Pass the declaration beside those values when initializing euler-train:

import euler_train

run = euler_train.init(
    config=config,
    metric_naming=metrics.training_naming_config(),
    stream=stream,
)
run.log(values, step=step, epoch=epoch)

Stages are optional. Omit stages= and build names with metrics.loss("depth", metric="mae") when a model has no staged pipeline. Invalid modalities, stages, or name segments raise ValueError at the point of construction.

Evaluation envelopes

Evaluation schemas often use axes such as space, category, and reduction rather than training's kind and stage. Supply those declarations directly:

from euler_metric_naming import AxisDeclaration, MetricDescription, MetricNamespace

evaluation = MetricNamespace(
    producer="euler_eval.depth",
    producer_version="2.0.0",
    modalities=("depth",),
    context="eval",
    axes={
        "space": AxisDeclaration(
            position=0,
            values=("native", "metric"),
        ),
        "reduction": AxisDeclaration(
            position=1,
            values=("image_mean", "pixel_pool"),
            optional=True,
        ),
    },
    descriptions={
        "absrel": MetricDescription(is_higher_better=False),
    },
)

metric_set = evaluation.metric_set_envelope("depth")

The resulting JSON-ready envelope declares depth.eval, its axes, producer provenance, and the display semantics of absrel. euler-eval places this object under metricSet next to the metric tree.

Read and filter names

from euler_metric_naming import decompose, filter_kind

parsed = decompose(
    "depth.train.loss.prior.log_radius",
    "depth.train",
    metrics.axes("depth"),
)

parsed.axes       # {"kind": "loss", "stage": "prior"}
parsed.metric     # "log_radius"
parsed.recompose()  # "depth.train.loss.prior.log_radius"

losses = filter_kind(values, metrics, "depth", "loss")

The public helpers also include recompose, compare_stages, filter_glob, and validate_metric_name. See the API guide for payload shapes, description fields, matching behavior, and naming constraints.

Comparison contract

Results files of euler-eval carry a protocol block that says how the evaluation was set up. Schema 2 of that block — defined in docs/contract.md — lets a consumer judge any two evaluations, of any modality, with one generic algorithm: every parameter, observation, reference, stratification, reducer and metric definition travels with its descriptor, so a new metric or a whole new modality needs no consumer change.

from euler_metric_naming.contract import compare_files, load_eval_file

verdict = compare_files(
    load_eval_file("depthpro/.eval/depth/eval.json"),
    load_eval_file("mari/.eval/depth/eval.json"),
    "depth.eval.metric.standard.image_mean.absrel",
)
verdict.label   # "comparable · domain differs by 0.9 %"

A verdict is same protocol, compared on N shared files, comparable · <reason> or not comparable · <reason>. Producers build the block with ProtocolBuilder, which copies the terms they use from the shipped vocabularies (euler.core, euler.sky, euler.depth, euler.rgb, euler.rays, euler.points3d); schema-1 files are read through a frozen legacy adapter. The package also ships the JSON Schemas, a dependency-free TS port for consumers (euler_metric_naming/contract/ts/) and conformance fixtures both implementations pass. See docs/api.md and docs/vocabulary.md.

Development

git clone https://github.com/d-rothen/euler-metric-naming.git
cd euler-metric-naming
uv sync --extra dev                 # or: pip install -e ".[dev]"
uv run pytest
uv run ruff check .
python scripts/generate_ts.py        # after changing vocabularies, legacy table or schemas
python scripts/generate_fixtures.py  # after changing how fixture eval files are built

See CONTRIBUTING.md for test and release guidance.

License

MIT © Daniel Rothenpieler

Metadata

Release files for euler-metric-naming 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for euler-metric-naming 0.3.0
File Size Uploaded Provenance Actions
euler_metric_naming-0.3.0.tar.gz 171.6 kB Without provenance Details for euler_metric_naming-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for euler-metric-naming 0.3.0
File Interpreter ABI Platform Actions
euler_metric_naming-0.3.0-py3-none-any.whl Python 3 none any Details for euler_metric_naming-0.3.0-py3-none-any.whl

Total release size: 400.6 kB

Release files / euler_metric_naming-0.3.0.tar.gz

Download URL euler_metric_naming-0.3.0.tar.gz
Size 171.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1f5819bd7e04e172a8d83f67c82287afc99b729f12fd07daa9c9e41ba57cf787
BLAKE2b-256 checksum
How to use checksums
1c02af654189c766c238164542d2ae6634b1a739bd0c4cc65d80da73c6b76a9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / euler_metric_naming-0.3.0-py3-none-any.whl

Download URL euler_metric_naming-0.3.0-py3-none-any.whl
Size 229.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
994a174fd0eeda1852e81ced89e33c73b3d71b3c7303b83df46c84ad2eccf82e
BLAKE2b-256 checksum
How to use checksums
0d596fc3404607c1fae1c412daefe7fce51b0e619bd5b905b0971a3dcfdd05bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for euler-metric-naming 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page