This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- AVOID inline comments in code!!!
- Don't create a .changeset file manually in the PR. Once you create a PR, a GH action will create it automatically based on the PR title
# Install with development dependencies
pip install -e .[dev,tensorboard]# Run all tests
pytest
# Run specific test file
pytest tests/test_run.py
# Run e2e tests
pytest tests/e2e/# Format and lint code (required before commits)
ruff check --fix --select I && ruff format# Launch dashboard for all projects
trackio show
# Launch dashboard for specific project
trackio show --project "project_name"Trackio is a lightweight experiment tracking library that provides a drop-in replacement for Weights & Biases (wandb). The architecture follows a clean separation between the API layer, UI layer, and storage layer.
- User API (
trackio/__init__.py,run.py) - Provides wandb-compatible API (init(),log(),finish()) - Storage Layer (
sqlite_storage.py) - Manages SQLite database operations for local persistence - API Layer (
ui/main.py) - Gradio-based API server exposing endpoints viagr.api() - Frontend (
frontend/) - Svelte 5 SPA dashboard served alongside the Gradio API - Background Sync (
commit_scheduler.py) - Optional Hugging Face dataset synchronization
Local-First Architecture: All data is stored locally in SQLite databases at ~/.cache/huggingface/trackio/. The system works completely offline by default.
Queued Logging: The Run class uses a queue-based system for logging to handle concurrent access safely. Background clients process log entries asynchronously.
Cloud Integration: Optional deployment to Hugging Face Spaces uses the deploy.py module. When deployed, data syncs to HF Datasets every 5 minutes via CommitScheduler.
Context Management: Uses Python context variables (context_vars.py) to track the current run across function calls, similar to wandb's approach.
Tests are split into unit tests (testing individual modules) and e2e tests (testing complete workflows). The conftest.py provides fixtures for temporary databases and test isolation. Always run tests before committing changes.
- Adding new logging features: Modify
run.py(Run class) andsqlite_storage.py(storage operations) - Changing UI/dashboard: Edit
frontend/src/(Svelte 5 components), then runnpm run buildintrackio/frontend/ - Changing API endpoints: Edit
ui/main.py(Gradio API layer) - Modifying API compatibility: Update
trackio/__init__.pyand ensure wandb compatibility - Adding import formats: Extend
imports.pywith new import functions - CLI modifications: Update
cli.pyand entry points inpyproject.toml
When asked to fix a GitHub issue and prepare a PR, use the following end-to-end workflow. The goal is to give reviewers observable before/after evidence, not only a patch and a passing unit test.
- Read the issue and comments with
gh issue view <number> --repo gradio-app/trackio --comments. - Fetch
origin/mainand create a dedicated worktree under../trackio-worktrees/issue-<number>from the fetched commit. - Use a branch such as
issue-<number>-<short-description>. Avoid assuming thefix/...namespace is available; this repository may have a branch literally namedfix. - Keep reproduction programs, generated data, Space staging files, screenshots, and issue metadata untracked. Never commit them with the fix.
-
Build the smallest realistic reproduction using the exact API, input, or metric name from the report. Name it
demo_issue_<number>.pywhen appropriate. -
Isolate local demo data by setting
TRACKIO_DIRto a directory inside the worktree. Include a known-good control metric or behavior when that makes the failure clearer. -
For frontend work, use the frontend's own lockfile and commands:
cd trackio/frontend npm ci npm run buildThe root pnpm install does not install
trackio/frontenddevelopment dependencies. -
Run the demo against the package in the worktree.
uv sync --extra devfollowed byuv run python demo_issue_<number>.pyis a convenient isolated setup. -
Confirm the reported failure before changing source. Inspect both sides of the data path when useful: verify the API/storage contains the expected values, then verify the browser or renderer loses or misrepresents them.
-
Prefer browser verification for UI bugs. If browser automation is unavailable, use the closest deterministic renderer/dataflow check, keep the live demo available for manual inspection, and state the limitation explicitly.
-
If the issue does not reproduce on current
origin/main, stop without editing code or opening a PR. Report the demo, command, observed result, and uncertainty.
- Keep the patch scoped to the confirmed failure and follow existing Trackio patterns.
- Add a regression test that exercises the actual boundary that failed. For frontend renderer bugs, test the renderer/accessor semantics rather than only a string helper.
- Cover adjacent syntax or edge cases only when the same root cause handles them; do not broaden the PR into unrelated cleanup.
Rerun the reproduction and the narrowest relevant tests, then run the complete checks for the changed area.
For frontend changes:
cd trackio/frontend
npm test
npm run lint
npm run buildFor Python changes, run the relevant pytest files and Ruff checks described above. Use
git diff --check before committing. Record exact commands and any environment-related
limitation.
- Confirm temporary demo and data files are still untracked with
git status --short. - Stage and commit only the required source and test files.
- Do not create a
.changesetmanually. The Trackio GitHub workflow creates one from the PR title and commits it to the branch. - Push the issue branch and open a draft PR against
gradio-app/trackio. - Keep the PR body short and include:
Fixes #<number>- the root cause and fix
- verification commands
- the minimal demo in a fenced code block
- a note that the demo file was not committed
- Leave the verified local demo server running and report its URL.
- Watch required checks with
gh pr checks <pr> --repo gradio-app/trackio --watch. - Treat test, lint, build, documentation, wheel, and Trackio Spaces E2E failures as defects in the change until evidence shows otherwise.
- Before fixing a suspected unrelated failure, compare recent
mainruns or reproduce it on a clean checkout. Rerun a likely flake once. Do not add unrelated fixes to the issue PR. - The changeset bot pushes to the PR branch. Fetch and fast-forward/rebase before any later push to avoid a non-fast-forward rejection.
- The preview-wheel upload and its PR-comment step are separate. If the comment step
fails, inspect the
PR wheel preview deploylogs; the wheel may already be uploaded and its exact URL will appear in the workflow inputs.
When the behavior is visible in a Trackio dashboard and the demo is safe to make public, deploy a comparison pair such as:
<namespace>/trackio-<issue>-before<namespace>/trackio-<issue>-after
Use these rules:
- Upload byte-identical, ordinary
app.pyfiles to both Spaces. The app should show the real behavior directly; do not build an in-page PASS/FAIL test harness. - The only functional difference should be
requirements.txt:- before:
trackio(latest released package) - after: the exact preview-wheel URL produced by the PR workflow
- before:
- A minimal Trackio Space can log its demonstration data at startup and finish with
trackio.show(project=...). Use the Gradio Space SDK, matching Trackio's own deploy template. - Give each Space a short README that explains what to inspect, says whether it is the released or PR version, and links to the other Space.
- Wait for both runtimes to reach
RUNNING. Read backapp.pyand requirements from the Hub, verify the app hashes match, verify both APIs serve the same demo data, and confirm the visual difference in a browser whenever one is available. - Never upload credentials, private user data, or the local Trackio cache. If a public demonstration is inappropriate or impossible, explain why and skip the Spaces.
- Add or update one PR comment containing both links and a compact before/after table.
Keep a stable HTML marker such as
<!-- trackio-before-after-spaces -->so reruns can update the comment instead of duplicating it.
Report the worktree, branch, untracked demo path, local demo URL, draft PR, required CI status, both Space URLs, what reviewers should observe, and any remaining caveat. Ask the reviewer to open both Spaces and confirm the visible difference.