Skip to main content

Typed Python client for the Syvain Metrics REST API

Project description

Syvain Metrics API Client

Typed Python client for the Syvain Metrics REST API.

This package maps directly onto the REST surface for experiments, folders, metric query endpoints, annotations, and ingestion keys. If you only need to record metrics from a training or evaluation job, use syvain-metrics-collector instead.

Install

uv add syvain-metrics-api-client

Authentication

Use an explicit API key:

from syvain_metrics_api_client import SyvainMetricsApiClient

client = SyvainMetricsApiClient("ak_org_...")

Use installed Syvain CLI auth:

client = SyvainMetricsApiClient("local")

local reads ~/.config/syvain-metrics/auth.json.

Usage

from syvain_metrics_api_client import SyvainMetricsApiClient

client = SyvainMetricsApiClient("local")

experiment = client.create_experiment(
    "mamba-run-001",
    description="Baseline mamba training run",
    metadata={"model": "mamba"},
).experiment

client.ingest_metrics(
    experiment.id,
    [
        {
            "client_event_id": "mamba-run-001/loss/1",
            "name": "loss",
            "value": 0.42,
            "step": 1,
            "metadata": {"split": "train"},
        }
    ],
)

series = client.query_metric_series(
    [
        {
            "experiment_id": experiment.id,
            "metric_name": "loss",
            "filter": {
                "metadata_key": "split",
                "metadata_value": "train",
            },
        }
    ],
    x_axis="step",
    limit=500,
)
catalog = client.query_metrics_catalog([experiment.id])

Every metric must include a stable client_event_id. Reuse the same value when retrying the same event so ingestion can remain idempotent.

Metric metadata is validated against the series backend contract before a request is sent: it must be a flat str -> str mapping with at most 32 keys, 128 UTF-8 bytes per key, 512 UTF-8 bytes per value, and 4096 UTF-8 bytes in its canonical JSON representation.

Ingest and annotation creation calls mint and cache ingestion keys per experiment. General API calls use the configured API key directly.

Client Surface

Folders:

  • list_folders(...)
  • create_folder(...)
  • get_folder(...)
  • patch_folder(...)
  • rename_folder(...)
  • move_folder(...)

Experiments:

  • list_experiments(...)
  • create_experiment(...)
  • get_experiment(...)
  • update_experiment_status(...)
  • move_experiment(...)

Metrics:

  • query_metric_series(...)
  • query_metrics_catalog(...)
  • ingest_metrics(...)

Ingestion keys:

  • list_ingestion_keys(...)
  • create_ingestion_key(...)
  • revoke_ingestion_key(...)
  • forget_ingestion_credential(...)

Annotations:

  • list_annotations(...)
  • create_annotation(...)

Authentication:

  • auth_status()

Host and Timeouts

The client defaults to https://metrics.syvain.com.

client = SyvainMetricsApiClient(
    "ak_org_...",
    host="https://metrics.syvain.com",
    timeout=10.0,
    ingest_timeout=60.0,
)

timeout applies to ordinary API calls. ingest_timeout applies to metric and annotation ingestion calls.

Write Retries and Idempotency

The client retries transient request failures for idempotent write operations. For POST and PATCH requests it sends a generated Idempotency-Key header and reuses that key across retry attempts for the same logical request.

Metric ingestion idempotency is controlled by each metric's client_event_id. Use deterministic IDs derived from the run, metric name, step, and series metadata when the same event may be retried by caller code.

Errors

All package-specific failures inherit from MetricsApiError.

  • MetricsApiRequestError: the API returned an HTTP error or could not be reached
  • MetricsApiResponseError: the API returned a successful response that did not match the expected schema
  • MetricsApiAuthError: local CLI auth was requested but unavailable or invalid

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

syvain_metrics_api_client-0.0.144.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

syvain_metrics_api_client-0.0.144-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file syvain_metrics_api_client-0.0.144.tar.gz.

File metadata

  • Download URL: syvain_metrics_api_client-0.0.144.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for syvain_metrics_api_client-0.0.144.tar.gz
Algorithm Hash digest
SHA256 2ed73da9db47b0232c09a02ffba96a209ace2f1dd0fb6af2b1bbadcee0de0592
MD5 3a1db371ff3b5a68916d96eaadeed564
BLAKE2b-256 ca4e71ad78b1bba2e001832d16d8ab0658b27f9539a5d6f4ded72f79d9f0841e

See more details on using hashes here.

File details

Details for the file syvain_metrics_api_client-0.0.144-py3-none-any.whl.

File metadata

  • Download URL: syvain_metrics_api_client-0.0.144-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for syvain_metrics_api_client-0.0.144-py3-none-any.whl
Algorithm Hash digest
SHA256 b5049a2254a2204bcf2f1239dd83b96d9f54238e63130453e0607a3d488b1c45
MD5 290ca8fdb5ab11fc75ef8fe91ee3b437
BLAKE2b-256 64045eeeb905c94d581f81517d3bc2e11703daa6e4d0e0145141ce679a85fe8b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page