Client¶
- class Beaker(config: Config, check_for_upgrades: bool = True, user_agent: str = 'beaker-py v2.4.3')[source]¶
A client for interacting with Beaker. This should be used as a context manager to ensure connections are properly closed on exit.
Tip
Use
from_env()
to create a client instance.- Parameters:
config – The Beaker
Config
.check_for_upgrades – Automatically check that beaker-py is up-to-date. You’ll see a warning if it isn’t.
user_agent – Override the “User-Agent” header used in requests to the Beaker server.
- classmethod from_env(check_for_upgrades: bool = True, user_agent: str = 'beaker-py v2.4.3', **overrides) Beaker [source]¶
Initialize client from a config file and/or environment variables.
- Examples:
>>> with Beaker.from_env(default_workspace="ai2/my-workspace") as beaker: ... print(beaker.user_name)
- Parameters:
check_for_upgrades – Automatically check that beaker-py is up-to-date. You’ll see a warning if it isn’t.
user_agent – Override the “User-Agent” header used in requests to the Beaker server.
overrides – Fields in the
Config
to override.
Note
This will use the same config file that the Beaker command-line client creates and uses, which is usually located at
$HOME/.beaker/config.yml
.If you haven’t configured the command-line client, then you can alternately just set the environment variable
BEAKER_TOKEN
to your Beaker user token.
- property organization: OrganizationClient¶
Manage organizations.
- property user: UserClient¶
Manage users.
- property workspace: WorkspaceClient¶
Manage workspaces.
- property cluster: ClusterClient¶
Manage clusters.
- property node: NodeClient¶
Manage nodes.
- property dataset: DatasetClient¶
Manage datasets.
- property image: ImageClient¶
Manage images.
- property experiment: ExperimentClient¶
Manage experiments.
- property workload: WorkloadClient¶
Manage workloads.
- property secret: SecretClient¶
Manage secrets.
- property group: GroupClient¶
Manage groups.
- property queue: QueueClient¶
Manage queues.
- class Config(user_token: str, agent_address: str = 'https://beaker.org', rpc_address: str = 'beaker.org:443', default_org: str | None = 'ai2', default_workspace: str | None = None, default_image: str | None = None)[source]¶
- user_token: str¶
Beaker user token that can be obtained from beaker.org.