Skip to main content

kymo — Python SDK

You hand kymo a dict of numbers and it gets them to a Kymo server, without slowing down or crashing the loop that produced them.

  • run.log() costs well under a microsecond: it shallow-copies your dict and appends it to a deque. Nothing else happens on your thread.
  • Flattening, value conversion, JSON, gzip, HTTP, retries and the disk spool all run on background daemon threads.
  • Nothing in this package raises into your code. Problems are reported as warnings on the kymo logger.
  • There are no runtime dependencies (stdlib only), and it needs Python ≥ 3.9. kymo works with any framework, because it doesn't know about any of them.
pip install kymo-logger         # or: uv add kymo-logger
export KYMO_HOST=https://kymo.example.com
export KYMO_API_KEY=kymo_...    # create one in the web UI: Settings → API tokens

The package is published on PyPI as kymo-logger (the name kymo belongs to an unrelated project); you still import kymo. To track unreleased changes on main instead, use a git source:

[tool.uv.sources]
kymo-logger = { git = "https://github.com/Kelvinlby/kymo", subdirectory = "sdk/python", branch = "main" }

Usage

import kymo

run = kymo.init(project="llm-pretrain", experiment="lr3e-4", config={"lr": 3e-4, "model": {"d": 4096}})
for step in range(1000):
    loss = 2.3 / (step + 1)
    run.log({"train/loss": loss, "lr": 3e-4, "eval": {"acc": 0.71, "loss": 2.4}}, step=step)
run.finish()   # optional: also done automatically at exit
  • Keys. Nested dicts become /-separated keys: the dict above logs train/loss, lr, eval/acc and eval/loss. The UI groups keys by the part before the first /.
  • Values.
    • Accepted:
      • ints and floats
      • bools, sent as 0/1
      • NaN and ±Inf, sent as "NaN" / "Infinity" / "-Infinity"
      • any object whose .item() returns a number
      • any object with __float__
    • Conversion happens later, on the background thread, so a value that is slow to read never blocks you.
    • Strings, None and other non-numeric values are dropped, with one warning per key.
  • step is optional. If you leave it out, it auto-increments (one past the previous step).
  • config is any JSON-like dict. It is sent once at init and shallow-merged into the experiment's config on the server.
  • Shortcuts. Module-level kymo.log(...), kymo.flush() and kymo.finish() act on the most recent run.
  • Context manager. with kymo.init(...) as run: marks the run failed if the block raises. Otherwise, at exit the run is marked finished, or failed when the interpreter exits because of an uncaught exception.

Logging from just one process

Every process that calls kymo.init logs. kymo does not inspect any launcher environment variables. When several workers run the same script, decide yourself who logs:

run = kymo.init(project="p", experiment="e", enabled=(worker_id == 0))
run.log({"loss": 1.2})   # a no-op on the other workers; no `if` needed around each call

To log from every worker, give each one its own experiment name or key prefix, e.g. {f"worker{worker_id}/loss": ...}.

After os.fork() the child's inherited runs turn into no-ops. The child can call kymo.init again to start its own run.

Offline use and the disk spool

  • Retries. Network errors, 429 and 5xx are retried with exponential backoff and full jitter (0.5 s doubling to a 60 s cap), honoring Retry-After.
  • No retry. 400/401/403 are never retried: kymo logs one warning and drops the batch.
  • 413. The batch is split in half and resent.
  • Memory, then disk. Unsent batches stay in memory up to max_memory_bytes (256 MiB by default). Beyond that, they spill to the spool directory (KYMO_CACHE_DIR).
  • Exit. kymo flushes for up to KYMO_EXIT_TIMEOUT seconds, then writes whatever is left to the spool.
  • Replay. Spooled files are replayed automatically by the next run that uses the same host and token. Replays are idempotent, because the server upserts by (key, step).
python -m kymo sync             # replay the spool now (uses KYMO_HOST / KYMO_API_KEY)
python -m kymo sync --dry-run   # just list what would be sent; also --dir, --all-hosts, --host, --api-key

On a machine without network access, set KYMO_OFFLINE=1; everything goes to the spool. Later, copy the spool directory to a machine that can reach the server and run python -m kymo sync there, with KYMO_CACHE_DIR pointing at the copy. Without an API key, kymo also runs offline instead of losing data.

Proxies

Proxy settings come from HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY, in upper or lower case. kymo uses the same rules as urllib.request.getproxies() and proxy_bypass(); ALL_PROXY is used as a fallback.

  • Plain http: requests go through the proxy with an absolute-URI request line.
  • https: kymo opens a CONNECT tunnel. TLS runs end to end, and the certificate is verified against the real server name.
  • Credentials: http://user:pass@proxy:3128 is sent as Proxy-Authorization: Basic. Percent-encode special characters, e.g. @ → %40.
  • Connections: both modes keep the connection alive between batches.
  • SOCKS: SOCKS proxies are not supported. kymo connects directly and logs a warning.
export HTTPS_PROXY=http://alice:s3cr%40t@proxy.corp:3128
export NO_PROXY=localhost,127.0.0.1,.internal

Configuration

env var default meaning
KYMO_API_KEY – API token (kymo_...). Without one, the run is offline and spools to disk.
KYMO_HOST http://localhost:8080 server URL; a path prefix is allowed
KYMO_DISABLED – 1 makes everything a no-op
KYMO_OFFLINE – 1 only spools to disk
KYMO_CACHE_DIR ~/.cache/kymo/spool spool directory
KYMO_EXIT_TIMEOUT 30 seconds to flush at exit before spooling the rest
KYMO_HTTP_TIMEOUT 60 socket read timeout per request (the connect timeout is 10 s)
KYMO_CA_BUNDLE – CA file for https (SSL_CERT_FILE also works)
HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY – proxies (see above)

kymo.init takes these keyword arguments:

  • project and experiment (if experiment is omitted, it defaults to <hostname>-<timestamp>)
  • config, api_key, host
  • enabled (default True)
  • offline
  • flush_interval (default 1.0 s)
  • max_batch_points (default 10 000)
  • max_memory_bytes (default 256 MiB)

log() takes a shallow copy. If you mutate a nested dict right after logging it, the background thread may see the new values.

No SDK needed

The SDK is a convenience. Anything that can send an HTTP POST can log to the ingest endpoint directly. The single-point shorthand puts metrics at the top level. step is optional; if you leave it out, the server assigns the next step for that experiment.

curl -sS https://kymo.example.com/api/v1/ingest \
  -H "Authorization: Bearer $KYMO_API_KEY" -H "Content-Type: application/json" \
  -d '{"project":"p","experiment":"e","metrics":{"loss":1.2}}'

The full form sends many points per request, along with optional config and status:

curl -sS https://kymo.example.com/api/v1/ingest \
  -H "Authorization: Bearer $KYMO_API_KEY" -H "Content-Type: application/json" \
  -d '{"project":"p","experiment":"e","config":{"lr":0.0003},"status":"running",
       "points":[{"step":1,"ts":1732400000.1,"metrics":{"train/loss":2.31,"lr":0.0003}},
                 {"step":2,"metrics":{"train/loss":2.12,"grad_norm":"NaN"}}]}'

The project and experiment are created automatically. Values are JSON numbers, with "NaN" / "Infinity" / "-Infinity" as strings. You can also gzip the body and send Content-Encoding: gzip. A 200 response means the data is durably stored. See SPEC §3 for the details.

Development

cd sdk/python
uv run --with pytest pytest -q        # tests (fake ingest server, proxy and hanging server are in tests/fakes.py)
uv run python bench/bench_log.py      # hot-path benchmark

Metadata

Release files for kymo-logger 0.2.2

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

Source distribution (sdist)

Source distribution for kymo-logger 0.2.2
File Size Uploaded Provenance Actions
kymo_logger-0.2.2.tar.gz 40.1 kB With provenance Details for kymo_logger-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kymo-logger 0.2.2
File Interpreter ABI Platform Actions
kymo_logger-0.2.2-py3-none-any.whl Python 3 none any Details for kymo_logger-0.2.2-py3-none-any.whl

Total release size: 70.2 kB

Release files / kymo_logger-0.2.2.tar.gz

Download URL kymo_logger-0.2.2.tar.gz
Size 40.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7b3b33883198e1da156341d16770033078dd8b1d2e28b885948dae8650be83cb
BLAKE2b-256 checksum
How to use checksums
b5b016b85b2e9fb5ce172c96f62d7001d3b3dd5d674b1a800667e3954e9db335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / kymo_logger-0.2.2-py3-none-any.whl

Download URL kymo_logger-0.2.2-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c23953af2119100289448ffd4ae17bd880f832a83214c53e404522678670384
BLAKE2b-256 checksum
How to use checksums
15b723ab8a55987728604b45e331794279d405013295e9372c0143499ff28e48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for kymo-logger 0.2.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kymo_logger-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

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