Save Your Work

Valohai automatically versions your notebook's final state when you stop it. You can also save outputs and log metrics while working, just like you would in a standard execution.

Automatic Versioning

Every time you stop a notebook, Valohai saves:

  • The final .ipynb file with all cell outputs

  • Any files written to /valohai/outputs/

  • Metadata logs you've created during the session

This means you can always return to previous notebook states. Your work is versioned without extra effort.

Save Files During Your Session

Write files to the outputs directory to version them:

import valohai

# Save a model file
output_path = valohai.outputs().path("model.h5")
model.save(output_path)

# Or use the direct path
output_path = "/valohai/outputs/model.h5"
model.save(output_path)

Files saved to /valohai/outputs/ appear in your notebook execution's outputs tab. You can download them, use them as inputs in other jobs, or register them as model versions.

Log Metrics and Metadata

Track metrics during training or experimentation using valohai-utils:

import valohai

for i in range(10):
    with valohai.metadata.logger() as logger:
        logger.log("iteration", i)
        logger.log("accuracy", model.accuracy)
        logger.log("loss", model.loss)

These logs appear in the Valohai UI under your notebook execution's metadata tab. You can visualize them, compare across runs, or export them for analysis.

💡 Tip: Use the same logging approach in notebooks and executions. This makes it easier to migrate code later.

Run and Version as a Standard Execution

Once your notebook code is working, you can run it end-to-end as a versioned execution using the Run Remote button.

Setup with valohai.prepare

Add a cell at the top of your notebook to define the execution configuration:

import valohai

valohai.prepare(
    step='training-experiment',
    image='python:3.9',
    default_inputs={
        'dataset': 's3://mybucket/data/train.csv'
    },
    default_parameters={
        'learning_rate': 0.001,
        'epochs': 10
    }
)

This tells Valohai how to run your notebook as a standalone job.

Run Remote

Click the Run Remote button in Jupyter. Valohai will:

  1. Execute your notebook top-to-bottom in a fresh environment

  2. Create a standard execution (not a notebook execution)

  3. Version the code, outputs, and metadata

The new execution runs independently—you can close your notebook, and the job continues. Your teammates can also run the same code without needing to interact with Jupyter.

💡 When to use Run Remote: Use this when you want to version a specific experiment, share reproducible results, or test your notebook in a clean environment before migrating to valohai.yaml.

Next Steps

Last updated

Was this helpful?