Beaker Gantry

3.7.0 · active · verified Thu Apr 16

Beaker Gantry (beaker-gantry) is a command-line interface (CLI) tool and Python library that streamlines running Python experiments in Beaker. It manages containers and boilerplate, eliminating the need for manual Dockerfile creation or complex Beaker YAML experiment specifications. Gantry automatically handles environment setup, repository cloning, and workload management at runtime, making it ideal for Python-based batch jobs from rapidly changing Git repositories. It is actively maintained with frequent updates.

Common errors

Warnings

Install

Imports

Quickstart

While primarily a CLI tool, `beaker-gantry` interacts with Beaker. This quickstart demonstrates how to verify your Beaker token (a prerequisite) and shows the most basic CLI command to run an experiment. It also hints at the Python API for logging metrics from within a running experiment. Ensure you have committed and pushed your changes to a Git repository before running `gantry run`.

import os

# Ensure BEAKER_TOKEN is set in your environment
BEAKER_TOKEN = os.environ.get('BEAKER_TOKEN', 'YOUR_BEAKER_TOKEN')
if not BEAKER_TOKEN or BEAKER_TOKEN == 'YOUR_BEAKER_TOKEN':
    print("Warning: Please set the BEAKER_TOKEN environment variable.")
    print("You can obtain it from your Beaker profile page.")
else:
    print("Beaker token is set. To run an experiment, ensure you are in a Git repository")
    print("and execute: gantry run --show-logs -- python -c 'print(\"Hello, Beaker Gantry!\")'")
    print("For programmatic metric logging from within an experiment:")
    print("  from gantry.api import write_metrics")
    print("  write_metrics({'accuracy': 0.95, 'loss': 0.05})")

view raw JSON →