bundle.lambdalabs¶
Lambda Labs cloud GPU integration for TheBundle.
Submodules¶
Exceptions¶
Common base class for all non-exit exceptions. |
Classes¶
Async client for the Lambda Labs Cloud API v1. |
|
Base data model class, providing utilities for serialization and deserialization |
|
A Lambda Labs persistent NFS filesystem. |
|
Base data model class, providing utilities for serialization and deserialization |
|
str(object='') -> str |
|
Base data model class, providing utilities for serialization and deserialization |
|
Base data model class, providing utilities for serialization and deserialization |
|
Manages a single remote training job on Lambda Labs. |
Package Contents¶
- exception bundle.lambdalabs.LambdaApiError(status_code: int, message: str)¶
Bases:
ExceptionCommon base class for all non-exit exceptions.
- status_code¶
- class bundle.lambdalabs.LambdaClient(api_key: str)¶
Async client for the Lambda Labs Cloud API v1.
- Usage:
- async with LambdaClient(api_key=”…”) as client:
types = await client.instance_types() instance = await client.launch(“gpu_1x_a10”, ssh_key_names=[“mykey”]) await client.wait_active(instance.id) await client.terminate([instance.id])
- async instance_types() dict[str, bundle.lambdalabs.models.InstanceType]¶
Return available instance types keyed by name.
- async instances() list[bundle.lambdalabs.models.Instance]¶
Return all active instances.
- async get_instance(instance_id: str) bundle.lambdalabs.models.Instance¶
Return a single instance by ID.
- async filesystems() list[bundle.lambdalabs.models.Filesystem]¶
Return all filesystems in the account.
- async create_filesystem(name: str, region_name: str = 'us-east-1') bundle.lambdalabs.models.Filesystem¶
Create a persistent filesystem.
- async launch(instance_type_name: str, ssh_key_names: list[str], region_name: str = 'us-east-1', name: str | None = None, quantity: int = 1, file_system_names: list[str] | None = None) list[str]¶
Launch instances. Returns list of instance IDs.
- async terminate(instance_ids: list[str]) list[str]¶
Terminate instances. Returns list of terminated instance IDs.
- async ssh_keys() list[bundle.lambdalabs.models.SshKey]¶
Return all SSH keys in the account.
- async add_ssh_key(name: str, public_key: str) bundle.lambdalabs.models.SshKey¶
Add an SSH key to the account.
- async wait_active(instance_id: str, poll_interval: float = DEFAULT_POLL_INTERVAL, timeout: float = 600) bundle.lambdalabs.models.Instance¶
Poll until the instance is active with an IP. Raises TimeoutError on timeout.
- class bundle.lambdalabs.LambdaLabsConfig(/, **data: Any)¶
Bases:
bundle.core.data.DataBase data model class, providing utilities for serialization and deserialization from/to JSON, along with JSON Schema generation.
- model_config¶
Default model configuration settings.
- classmethod load() LambdaLabsConfig¶
- class bundle.lambdalabs.Filesystem(/, **data: Any)¶
Bases:
bundle.core.data.DataA Lambda Labs persistent NFS filesystem.
Auto-mounted on instances at
/home/ubuntu/<name>/. Survives instance termination — ideal for storing datasets and results across multiple training jobs without re-uploading.- property path: pathlib.Path¶
Mount path on the instance.
- class bundle.lambdalabs.Instance(/, **data: Any)¶
Bases:
bundle.core.data.DataBase data model class, providing utilities for serialization and deserialization from/to JSON, along with JSON Schema generation.
- model_config¶
Default model configuration settings.
- status: InstanceStatus¶
- instance_type: InstanceType¶
- class bundle.lambdalabs.InstanceStatus¶
-
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- BOOTING = 'booting'¶
- ACTIVE = 'active'¶
- UNHEALTHY = 'unhealthy'¶
- TERMINATING = 'terminating'¶
- TERMINATED = 'terminated'¶
- class bundle.lambdalabs.InstanceType(/, **data: Any)¶
Bases:
bundle.core.data.DataBase data model class, providing utilities for serialization and deserialization from/to JSON, along with JSON Schema generation.
- model_config¶
Default model configuration settings.
- specs: InstanceSpecs¶
- class bundle.lambdalabs.SshKey(/, **data: Any)¶
Bases:
bundle.core.data.DataBase data model class, providing utilities for serialization and deserialization from/to JSON, along with JSON Schema generation.
- model_config¶
Default model configuration settings.
- class bundle.lambdalabs.RemoteJob(config: bundle.lambdalabs.config.LambdaLabsConfig | None = None, api_key: str | None = None, ssh_key_path: pathlib.Path | None = None, ssh_user: str = 'ubuntu', auto_terminate: bool = False, filesystem_name: str | None = None)¶
Manages a single remote training job on Lambda Labs.
- Lifecycle:
launch() — start a GPU instance (or attach to an existing one)
wait() — poll until active + has IP
setup() — install bundle on the remote instance
upload() — rsync local workspace → remote (skips unchanged files)
run() — execute a command via SSH
download() — rsync remote results → local
terminate()— shut down the instance (optional)
- Filesystem mode (recommended):
Pass
filesystem_nameto mount a Lambda Labs persistent NFS volume. The workspace lives at/home/ubuntu/<filesystem_name>/and survives instance termination — images and SfM output are never re-uploaded. Only the smallruns/results are downloaded after each job.
- config¶
- ssh_key_path¶
- ssh_user = 'ubuntu'¶
- auto_terminate = False¶
- instance: bundle.lambdalabs.models.Instance | None = None¶
- async launch(instance_type: str | None = None, ssh_key_name: str | None = None, region: str | None = None, name: str | None = None, instance_id: str | None = None) bundle.lambdalabs.models.Instance¶
Launch a new instance or attach to an existing one by ID.
- async wait(timeout: float = 600) bundle.lambdalabs.models.Instance¶
Poll until the instance is active with an IP.
- async upload(local: pathlib.Path, remote: pathlib.Path, skip_existing: bool = False) None¶
rsync local directory → remote instance.
When
skip_existing=True(set automatically in filesystem mode), files already on the remote are not re-transferred — saving time and bandwidth for large image datasets on subsequent runs.
- async download(remote: pathlib.Path, local: pathlib.Path) None¶
rsync remote directory → local.