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

  • experiment creation by name
  • metadata logging
  • metric logging
  • artifact upload
  • reconnection to an existing experiment
  • file download and metadata access

Was this page helpful?

What went wrong?

↑↓ Navigate↵ Open⌘↵ New tabesc Close