Checkpointing & Experiment Tracking πΎ
Local pipelines save a checkpoint after each successful step by default. Keep the run ID to resume that execution after an interruption. Calling run() without an ID starts a fresh execution.
Resume a local pipeline
from flowyml import Pipeline, step
@step(outputs=["examples"])
def load_data():
return [1, 2, 3]
@step(inputs=["examples"], outputs=["total"])
def summarize(examples):
return sum(examples)
pipeline = Pipeline.from_steps(load_data, summarize, name="summary")
result = pipeline.run(run_id="summary-001")
# After fixing a failure or restarting the process, construct the same pipeline.
result = pipeline.rerun("summary-001")
A rerun reads the checkpoint from the project's configured checkpoint directory. To recompute a particular step and those after it, pass from_step="summarize". To disable automatic checkpoints, set enable_checkpointing=False when creating the pipeline.
Inspect a saved output
from flowyml import PipelineCheckpoint
from flowyml.utils.config import get_config
checkpoint = PipelineCheckpoint("summary-001", get_config().checkpoint_dir)
if "load_data" in checkpoint.get_completed_steps():
examples = checkpoint.load_step_state("load_data")
print(examples) # [1, 2, 3]
π§ͺ Experiment Tracking
flowyml automatically tracks every pipeline run when you use Metrics objects, capturing parameters, metrics, and artifacts. This allows you to compare experiments and reproduce results without any additional setup.
Automatic Experiment Tracking
Experiment tracking is enabled by default! Simply use Metrics objects in your pipeline, and flowyml will automatically:
- Extract all metrics from
Metricsobjects - Capture context parameters (learning_rate, epochs, etc.)
- Log everything to the experiment tracking system
- Create an experiment named after your pipeline
Example:
from flowyml import Pipeline, step, context, Metrics
# Define context with parameters
ctx = context(
learning_rate=0.001,
batch_size=32,
epochs=10
)
@step(outputs=["metrics/evaluation"])
def evaluate_model():
"""Evaluate the trained model."""
metrics = {"test_accuracy": 0.93, "test_loss": 0.07}
# Return Metrics object - automatically logged to experiments!
return Metrics.create(
name="example_metrics",
metrics=metrics,
metadata={"source": "example"},
)
pipeline = Pipeline("training_pipeline", context=ctx)
pipeline.add_step(evaluate_model)
result = pipeline.run()
# Metrics are automatically logged! No additional code needed.
Manual Experiment Tracking
If you want more control, you can manually create and manage experiments:
from flowyml import Experiment
# Create experiment
exp = Experiment(
name="learning_rate_tuning",
description="Testing different learning rates"
)
# Log a run manually
exp.log_run(
run_id=result.run_id,
metrics={"accuracy": 0.95, "loss": 0.05},
parameters={"learning_rate": 0.001}
)
Comparing Experiments π
You can compare runs using the CLI or the Python API.
CLI:
# Compare two specific runs
flowyml experiment compare <run_id_1> <run_id_2>
# List all experiments
flowyml experiment list
# Inspect one of the recorded runs
flowyml runs inspect <run_id>
Python:
from flowyml import compare_runs, Experiment
# Compare runs using the utility function
diff = compare_runs(["run_1", "run_2"])
print(diff)
# Or use Experiment object
exp = Experiment("training_pipeline")
comparison = exp.compare_runs()
best_run = exp.get_best_run(metric="accuracy", maximize=True)
Disabling Automatic Tracking βΈοΈ
If you want to disable automatic experiment tracking:
from flowyml.utils.config import update_config
# Disable auto-logging globally
update_config(auto_log_metrics=False)
# Or disable for a specific pipeline
pipeline = Pipeline("my_pipeline", enable_experiment_tracking=False)
Visualizing Experiments π
The flowyml UI provides a dedicated Experiments view where you can: - View a table of all runs - Filter by parameters or metrics - Plot metric trends over time - Compare side-by-side details of selected runs
Access it at http://localhost:8080/experiments when the UI is running.
π Selective Re-Execution β‘NEW
Resume pipelines from a specific point, re-using cached results from previous steps.
Automatic Resume
When checkpointing is enabled (default), FlowyML automatically detects completed steps and skips them on retry:
pipeline = Pipeline("training") # Checkpointing enabled by default
pipeline.add_step(load_data) # β
Already completed β skipped
pipeline.add_step(preprocess) # β
Already completed β skipped
pipeline.add_step(train_model) # β Failed last time β re-executed
pipeline.add_step(evaluate) # β³ Never ran β executed
# Re-run: automatically resumes from train_model
result = pipeline.run(run_id="previous-run-id")
The pipeline.rerun() API
Explicitly resume a pipeline from a previous checkpoint:
# Resume from last checkpoint (skip all completed steps)
result = pipeline.rerun(run_id="abc-123")
# Resume from a specific step (re-run train_model and everything after)
result = pipeline.rerun(run_id="abc-123", from_step="train_model")
If no checkpoint exists for the given run_id, a clear ValueError is raised.
How It Works
- FlowyML commits each successful step's return value, including
None, before marking it complete in the checkpoint. - A normal rerun restores completed steps in their recorded order. If a grouped execution stopped halfway through, its unfinished steps resume together.
- With
from_step, FlowyML invalidates that step and later results before starting. If the rerun fails, another retry resumes from its last committed step.
New checkpoints preserve the original return type. Older checkpoints that recorded several named outputs without recording the return type restore those values as a tuple.
Pipeline Snapshots for Reproducibility
Each run automatically captures an immutable snapshot of the pipeline definition:
from flowyml import freeze_pipeline
snapshot = freeze_pipeline(pipeline)
print(snapshot.snapshot_hash) # SHA-256 of entire definition
print(snapshot.step_hashes) # Per-step code hashes
assert snapshot.verify() # Verify integrity hasn't changed
The snapshot hash is also stored in PipelineResult.snapshot_hash for each run.
Tip
Use PipelineSnapshot.verify() to confirm a pipeline hasn't been modified since a previous run β essential for auditing and compliance.