latch package#



latch.account module#

class latch.account.Account(id: str)[source]#

Bases: object

User or team workspace. Can be used to fetch related resources.

current() is the typical way of getting an Account.

If the current request signer (CLI user or execution context) lacks permissions to fetch some information, the corresponding operations will act as if the information does not exist. Update operations will usually produce errors.

id: str#

Unique identifier.

classmethod current() Self[source]#

Get current account.

In an execution context, this is the workspace in which the execution was run.

In the CLI context (when running latch commands) this is the current setting of latch workspace, which defaults to the user’s default workspace.


Current account.

load() None[source]#

(Re-)populate this account instance’s cache.

Future calls to most getters will return immediately without making a network request.

Always makes a network request.

list_registry_projects(*, load_if_missing: Literal[True] = True) List[Project][source]#
list_registry_projects(*, load_if_missing: bool) List[Project] | None

List Registry projects owned by this workspace.


load_if_missing – If true, load() the project list if not in cache. If false, return None if not in cache.


Projects owned by this workspace.

update(*, reload_on_commit: bool = True) Iterator[AccountUpdate][source]#

Start an update transaction.

The transaction will commit when the context manager closes unless an error occurs.

No changes will occur until the transaction commits.

The transaction can be cancelled by running AccountUpdate.clear() before closing the context manager.


reload_on_commit – If true, load() this account after the transaction commits.


Context manager for the new transaction.

class latch.account.AccountUpdate(account: latch.account.Account)[source]#

Bases: object

account: Account#
upsert_registry_project(display_name: str)[source]#

Upsert a registry project.

Not idempotent. Two calls with the same args will create two projects.


display_name – Display name of the new project.

delete_registry_project(id: str)[source]#

Delete a registry project.


id – The ID of the target project.

commit() None[source]#

Commit this account update transaction.

May be called multiple times.

All pending updates are committed with one network request.

Atomic. The entire transaction either commits or fails with an exception.


Remove pending updates.

May be called to cancel any pending updates that have not been committed.

latch.executions module#

class latch.executions.TaskIdentifier(token: str, node_name: str, retry: int, arr_index: int | None, arr_retry: int | None)[source]#

Bases: object

token: str#
node_name: str#
retry: int#
arr_index: int | None#
arr_retry: int | None#
latch.executions.get_task_identifier() TaskIdentifier | None[source]#
latch.executions.rename_current_execution(name: str)[source]#

Rename the current execution.

Useful for naming executions based on inputs. If this function is called outside of an execution context, it is a noop.

Module contents#

The Latch SDK

A commandline toolchain to define and register serverless workflows with the Latch platform.