Data Models#

class beaker.data_model.base.BaseModel(**data)[source]#

Bases: BaseModelV2

The base class for all Beaker data models.

classmethod from_json(json_data)[source]#
Return type:

TypeVar(T)

to_json()[source]#
Return type:

Dict[str, Any]

classmethod jsonify(x)[source]#
Return type:

Any

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Account#

class beaker.Account(**data)[source]#

Bases: BaseModel

id: str#
name: str#
display_name: str#
institution: Optional[str]#
pronouns: Optional[str]#
email: Optional[str]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Organization#

class beaker.Organization(**data)[source]#

Bases: BaseModel

id: str#
name: str#
description: str#
created: datetime#
display_name: str#
pronouns: Optional[str]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.OrganizationRole(value)[source]#

Bases: StrEnum

An enumeration.

admin = 'admin'#
member = 'member'#
class beaker.OrganizationMember(**data)[source]#

Bases: BaseModel

role: OrganizationRole#
organization: Organization#
user: Account#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Workspace#

class beaker.Workspace(**data)[source]#

Bases: BaseModel

id: str#
name: str#
full_name: str#
description: Optional[str]#
size: WorkspaceSize#
owner: Account#
author: Account#
created: datetime#
modified: datetime#
archived: bool#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.WorkspaceSize(**data)[source]#

Bases: BaseModel

datasets: int#
experiments: int#
groups: int#
images: int#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.WorkspaceRef(**data)[source]#

Bases: BaseModel

id: str#
name: str#
full_name: str#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.Permission(value)[source]#

Bases: StrEnum

Workspace permission levels.

no_permission = 'none'#
read = 'read'#
write = 'write'#
full_control = 'all'#
class beaker.WorkspacePermissions(**data)[source]#

Bases: BaseModel

requester_auth: str#
public: bool#
authorizations: Optional[Dict[str, Permission]]#

A dictionary of account IDs to authorizations.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Cluster#

class beaker.Cluster(**data)[source]#

Bases: BaseModel

id: str#
name: str#
full_name: str#
created: datetime#
autoscale: bool#
capacity: int#
preemptible: bool#
status: ClusterStatus#
status_message: Optional[str]#
node_spec: Optional[NodeResources]#

The requested node configuration.

node_shape: Optional[NodeResources]#

The actual node configuration.

node_cost: Optional[str]#
validated: Optional[datetime]#
user_restrictions: Optional[Tuple[str, ...]]#
allow_preemptible_restriction_exceptions: Optional[bool]#
compute_source: Optional[str]#
max_job_timeout: Optional[int]#
property is_cloud: bool#

Returns True is the cluster is a cloud cluster, otherwise False.

property is_active: bool#

Returns True if the cluster is ready to be used.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.ClusterStatus(value)[source]#

Bases: StrEnum

Current status of a cluster.

pending = 'pending'#
active = 'active'#
terminated = 'terminated'#
failed = 'failed'#
class beaker.ClusterUtilization(**data)[source]#

Bases: BaseModel

cluster: Cluster#
running_jobs: int#
queued_jobs: int#
running_preemptible_jobs: int#
nodes: Tuple[NodeUtilization, ...]#
property id: str#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.ClusterSpec(**data)[source]#

Bases: BaseModel

name: str#
capacity: int#
preemptible: bool#
spec: NodeResources#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.ClusterPatch(**data)[source]#

Bases: BaseModel

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

capacity: Optional[int]#
allow_preemptible_restriction_exceptions: Optional[bool]#

Node#

class beaker.Node(**data)[source]#

Bases: BaseModel

id: str#
hostname: str#
created: datetime#
limits: NodeResources#
expiry: Optional[datetime]#
cordoned: Optional[datetime]#
cordon_reason: Optional[str]#
cordon_agent_id: Optional[str]#
cluster_id: Optional[str]#
account_id: Optional[str]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.NodeResources(**data)[source]#

Bases: BaseModel

cpu_count: Optional[float]#
memory: Optional[str]#
gpu_count: Optional[int]#
gpu_type: Optional[str]#
gpu_ids: Optional[Tuple[str, ...]]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.NodeUtilization(**data)[source]#

Bases: BaseModel

id: str#
hostname: str#
limits: NodeResources#
running_jobs: int#
running_preemptible_jobs: int#
used: NodeResources#
free: NodeResources#
cordoned: bool#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Dataset#

class beaker.Dataset(**data)[source]#

Bases: BaseModel

id: str#
name: Optional[str]#
full_name: Optional[str]#
description: Optional[str]#
author: Account#
created: datetime#
committed: Optional[datetime]#
workspace_ref: WorkspaceRef#
source_execution: Optional[str]#
storage: Optional[DatasetStorage]#
property display_name: str#
property workspace: WorkspaceRef#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.DatasetStorage(**data)[source]#

Bases: BaseModel

id: str#
token: str#
token_expires: datetime#
address: Optional[str]#
url: Optional[str]#
urlv2: Optional[str]#
total_size: Optional[int]#
num_files: Optional[int]#
property scheme: str | None#
property base_url: str#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.FileInfo(**data)[source]#

Bases: BaseModel

path: str#

The path of the file within the dataset.

updated: datetime#

The time that the file was last updated.

digest: Optional[Digest]#

The digest of the contents of the file.

size: Optional[int]#

The size of the file in bytes, if known.

IGNORE_FIELDS: ClassVar[Set[str]] = {'url'}#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.Digest(*args, value: str, algorithm: DigestHashAlgorithm)[source]#

Bases: BaseModel

A digest is a checksum / hash of a files contents. These are used to verify the integrity of files downloaded from Beaker datasets.

value: str#

The hex-encoded value of the digest.

algorithm: DigestHashAlgorithm#

The algorithm used to create and verify the digest.

classmethod from_encoded(encoded)[source]#

Initialize a digest from a string encoding of the form {ALGORITHM} {ENCODED_STRING}, e.g. SHA256 iA02Sx8UNLYvMi49fDwdGjyy5ssU+ttuN1L4L3/JvZA=.

Parameters:

encoded (str) – The string encoding of the digest.

Return type:

Digest

classmethod from_decoded(decoded, algorithm)[source]#

Initialize a digest from raw bytes.

Parameters:
  • decoded (bytes) – The raw bytes of the digest.

  • algorithm (Union[str, DigestHashAlgorithm]) – The algorithm used to produce the bytes of the digest from the contents of the corresponding file.

Return type:

Digest

encode()[source]#

Encode the digest into its string form.

This is the inverse of from_encoded().

Return type:

str

decode()[source]#

Decode a digest into its raw bytes form.

This is the inverse of from_decoded().

Return type:

bytes

new_hasher()[source]#

Get a fresh hasher object for the given algorithm.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.DigestHashAlgorithm(value)[source]#

Bases: StrEnum

Supported hash algorithms for file Digest.

SHA256 = 'SHA256'#
SHA512 = 'SHA512'#
MD5 = 'MD5'#
hasher()[source]#

Get a hasher object for the given algorithm.

Image#

class beaker.Image(**data)[source]#

Bases: BaseModel

id: str#
owner: Account#
author: Account#
created: datetime#
workspace_ref: WorkspaceRef#
original_tag: Optional[str]#
docker_tag: Optional[str]#
name: Optional[str]#
full_name: Optional[str]#
description: Optional[str]#
committed: Optional[datetime]#
size: Optional[int]#
property display_name: str#
property workspace: WorkspaceRef#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Job#

class beaker.Job(**data)[source]#

Bases: BaseModel

A Job is an execution of a Task.

Tip

You can check a job’s exit code with job.status.exit_code.

id: str#
kind: JobKind#
author: Account#
workspace: str#
status: JobStatus#
name: Optional[str]#
cluster: Optional[str]#
execution: Optional[JobExecution]#
node: Optional[str]#
requests: Optional[JobRequests]#
limits: Optional[JobLimits]#
session: Optional[Session]#
host_networking: bool#
port_mappings: Optional[Dict[str, int]]#
result: Optional[ExecutionResult]#
property display_name: str#
property is_finalized: bool#
property is_done: bool#

Same as is_finalized(), kept for backwards compatibility.

property was_preempted: bool#
property priority: Priority | None#

Get the priority of the job.

check()[source]#
Raises:

JobFailedError – If the job failed or was canceled.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.JobKind(value)[source]#

Bases: StrEnum

The kind of job.

execution = 'execution'#
session = 'session'#
class beaker.CurrentJobStatus(value)[source]#

Bases: StrEnum

The status of a job.

created = 'created'#
scheduled = 'scheduled'#
running = 'running'#
idle = 'idle'#
exited = 'exited'#
failed = 'failed'#
finalized = 'finalized'#
canceled = 'canceled'#
preempted = 'preempted'#
class beaker.CanceledCode(value)[source]#

Bases: IntEnum

An enumeration.

not_set = 0#
system_preemption = 1#
user_preemption = 2#
idle = 3#
manual_cancellation = 4#
class beaker.JobStatus(**data)[source]#

Bases: BaseModel

created: datetime#
scheduled: Optional[datetime]#
started: Optional[datetime]#
exited: Optional[datetime]#
failed: Optional[datetime]#
finalized: Optional[datetime]#
canceled: Optional[datetime]#
canceled_for: Optional[str]#
canceled_code: Union[CanceledCode, int, None]#
idle_since: Optional[datetime]#
ready: Optional[datetime]#
exit_code: Optional[int]#
message: Optional[str]#
property current: CurrentJobStatus#

Get the CurrentJobStatus.

Raises:

ValueError – If status can’t be determined.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.ExecutionResult(**data)[source]#

Bases: BaseModel

beaker: Optional[str]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.JobRequests(**data)[source]#

Bases: BaseModel

gpu_count: Optional[int]#
cpu_count: Optional[float]#
memory: Optional[str]#
shared_memory: Optional[str]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.JobExecution(**data)[source]#

Bases: BaseModel

task: str#
experiment: str#
spec: TaskSpec#
result: ExecutionResult#
workspace: Optional[str]#
replica_rank: Optional[int]#
replica_group_id: Optional[str]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.JobLimits(**data)[source]#

Bases: BaseModel

cpu_count: Optional[float]#
memory: Optional[str]#
gpus: Tuple[str, ...]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.Session(**data)[source]#

Bases: BaseModel

command: Optional[Tuple[str, ...]]#
env_vars: Optional[Tuple[EnvVar, ...]]#
datasets: Optional[Tuple[DataMount, ...]]#
image: Optional[ImageSource]#
save_image: bool#
ports: Optional[Tuple[int, ...]]#
ports_v2: Optional[Tuple[Tuple[int, int], ...]]#
priority: Optional[Priority]#
work_dir: Optional[str]#
identity: Optional[str]#
constraints: Optional[Dict[str, List[str]]]#
result: Optional[ResultSpec]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Experiment#

class beaker.Experiment(**data)[source]#

Bases: BaseModel

id: str#
name: Optional[str]#
full_name: Optional[str]#
description: Optional[str]#
author: Account#
created: datetime#
workspace_ref: WorkspaceRef#
jobs: Tuple[Job, ...]#
property display_name: str#
property workspace: WorkspaceRef#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.Task(**data)[source]#

Bases: BaseModel

id: str#
name: Optional[str]#
experiment_id: str#
author: Account#
created: datetime#
schedulable: bool#
jobs: Tuple[Job, ...]#
owner: Optional[Account]#
replica_rank: Optional[int]#
property display_name: str#
property latest_job: Job | None#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class beaker.Tasks(tasks)[source]#

Bases: MappedSequence[Task]

A sequence of Task that also behaves like a mapping of task names to tasks, i.e. you can use get() or __getitem__() with the name of the task.

Secret#

class beaker.Secret(**data)[source]#

Bases: BaseModel

name: str#
created: datetime#
updated: datetime#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Group#

class beaker.Group(**data)[source]#

Bases: BaseModel

id: str#
name: Optional[str]#
full_name: Optional[str]#
owner: Account#
author: Account#
created: datetime#
modified: datetime#
workspace_ref: Optional[WorkspaceRef]#
description: Optional[str]#
property workspace: WorkspaceRef | None#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.