Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Beaker-py

A lightweight pure-Python client for Beaker.

Installing

Installing with pip

beaker-py is available on PyPI. Just run

pip install beaker-py

Installing from source

To install beaker-py from source, first clone the repository:

git clone https://github.com/allenai/beaker.git

Then create or activate a Python virtual environment, and run:

cd beaker/bindings/python
make dev-install

Quick start

If you've already configured the Beaker command-line client, beaker-py will find and use the existing configuration file (usually located at $HOME/.beaker/config.yml) or BEAKER_TOKEN environment variable.

Then you can instantiate the Beaker client with the .from_env() class method:

from beaker import Beaker

with Beaker.from_env() as beaker:
    ...

With the Python client, you can:

  • Query Clusters with beaker.cluster.* methods, e.g. beaker.cluster.get("ai2/jupiter-cirrascale-2").
  • Manage Datasets with beaker.dataset.* methods, e.g. beaker.dataset.create(dataset_name, source_dir).
  • Submit, track, and find Experiments with beaker.experiment.*, beaker.workload.*, and beaker.job.* methods, e.g. beaker.experiment.create(spec=spec, name=name).
  • Manage Workspaces with beaker.workspace.* methods, e.g. beaker.workspace.create("ai2/new_workspace").
  • Manage Secrets with beaker.secret.* methods, e.g. beaker.secret.write(name, value).

Example workflow

Launch and follow an experiment like beaker-gantry does:

import time
from beaker import Beaker, BeakerExperimentSpec, BeakerJobPriority


with Beaker.from_env() as beaker:
    # Build experiment spec...
    spec = BeakerExperimentSpec.new(
        description="beaker-py test run",
        beaker_image="petew/hello-world",
        priority=BeakerJobPriority.low,
        preemptible=True,
    )

    # Create experiment workload...
    workload = beaker.experiment.create(spec=spec)

    # Wait for job to be created...
    while (job := beaker.workload.get_latest_job(workload)) is None:
        print("waiting for job to start...")
        time.sleep(1.0)

    # Follow logs...
    print("Job logs:")
    for job_log in beaker.job.logs(job, follow=True):
        print(job_log.message.decode())

Development

After installing from source, you can run checks and tests locally with:

make checks

Releases

At the moment releases need to be published manually by following these steps:

  1. Ensure you've authenticated with PyPI through a ~/.pypirc file and have write permissions to the beaker-py project.
  2. Ensure the target release version defined in src/beaker/version.py is correct, or change the version on the fly by adding the Make argument BEAKER_PY_VERSION=X.X.X to the command in the next step.
  3. Run make publish for a stable release or make publish-nightly for a nightly pre-release.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beaker_py-2.0.1.dev20250430.tar.gz (71.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beaker_py-2.0.1.dev20250430-py3-none-any.whl (79.8 kB view details)

Uploaded Python 3

File details

Details for the file beaker_py-2.0.1.dev20250430.tar.gz.

File metadata

  • Download URL: beaker_py-2.0.1.dev20250430.tar.gz
  • Upload date:
  • Size: 71.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for beaker_py-2.0.1.dev20250430.tar.gz
Algorithm Hash digest
SHA256 02200216a7b362a127be152e7a0c2d122c2d3be124bd01f5b76dc6b5712a3a3d
MD5 218350ffe5ba938961ef217fa488edea
BLAKE2b-256 efd26a3806c5d55b19d1fba9b63bc13c237ab8080aefb74745096686d12fb324

See more details on using hashes here.

File details

Details for the file beaker_py-2.0.1.dev20250430-py3-none-any.whl.

File metadata

File hashes

Hashes for beaker_py-2.0.1.dev20250430-py3-none-any.whl
Algorithm Hash digest
SHA256 468e1ab68394e2f50131eef8c8c147a6fdc475aef1da92ca82da59ae0b7f0daa
MD5 a3c52f29f6759bb123c0760877214b46
BLAKE2b-256 19a31d9b6645f02314ec40bb4fe73ca6afcb957c661c114b40ed34d6e6f78743

See more details on using hashes here.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page