Complete Workflow

This tutorial covers a full experiment lifecycle:

  1. Initialize a run
  2. Log metadata, metrics, and artifacts
  3. Finalize
  4. Reconnect later
  5. Retrieve metadata and files

Comparing experiment metrics with charts

Train Script

import json

import litlogger
from litlogger import File

config = {"model": "ResNet50", "lr": 0.001}
with open("config.json", "w") as f:
    json.dump(config, f)

experiment = litlogger.init(name="image-classifier")

# Set metadata
experiment["model"] = "ResNet50"
experiment["dataset"] = "CIFAR10"

# Log a static file
experiment["config"] = File("config.json")

# Log training metrics
for epoch in range(10):
    experiment["loss"].append(1.0 / (epoch + 1), step=epoch)

experiment.finalize()

Fetch Script

"""Fetch data from a previously logged experiment.

This script resumes the 'image-classifier' experiment and reads back
metadata and artifacts using the dict-like API.
"""

import json

import litlogger

experiment = litlogger.init(name="image-classifier")

# Read metadata via property
metadata = experiment.metadata
print(f"Metadata: {metadata}")

# Read artifacts and download
artifacts = experiment.artifacts
if "config" in artifacts:
    artifacts["config"].save("/tmp/config.json")
    with open("/tmp/config.json") as f:
        print(f"Config: {json.load(f)}")

experiment.finalize()

What This Covers

  • Create experiment by name
  • Log metadata
  • Log metrics
  • Upload artifacts
  • Reconnect to an existing experiment
  • Download files and access metadata

Was this page helpful?

What went wrong?

↑↓ Navigate↵ Open⌘↵ New tabesc Close