Beaker Python Client

2.6.0 · active · verified Thu Apr 16

beaker-py is a lightweight, standalone, pure Python client for the Beaker platform, which is a machine learning experiment and dataset management system. It provides an RPC-based client to interact with Beaker servers. The library is actively maintained, with its latest version being 2.6.0, and follows a continuous release cadence.

Common errors

Warnings

Install

Imports

Quickstart

The quickstart demonstrates initializing the Beaker client using `Beaker.from_env()`, which automatically picks up configuration from `~/.beaker/config.yml` or the `BEAKER_TOKEN` environment variable. It then attempts to list datasets within a specified workspace.

import os
from beaker import Beaker

# Ensure BEAKER_TOKEN environment variable is set or a ~/.beaker/config.yml exists
# Example: export BEAKER_TOKEN="your_beaker_user_token"

# Or, for a quick demonstration without a real token (will likely fail auth):
# os.environ['BEAKER_TOKEN'] = os.environ.get('BEAKER_TOKEN', 'dummy-token-for-example')

try:
    # Instantiate the Beaker client, optionally specifying a default workspace
    with Beaker.from_env(default_workspace="your_org/your_workspace") as beaker:
        # Example: List datasets (requires proper auth and workspace)
        print(f"Beaker client initialized for workspace: {beaker.workspace.current.name}")
        datasets = beaker.dataset.list()
        if datasets:
            print(f"Found {len(datasets)} datasets, e.g., {datasets[0].name}")
        else:
            print("No datasets found or unable to list.")
except Exception as e:
    print(f"Failed to interact with Beaker: {e}")
    print("Please ensure BEAKER_TOKEN is set or ~/.beaker/config.yml is configured correctly.")

view raw JSON →