benchling_sdk.helpers.transaction_manager module¶

class AbortTransactionCall¶

Bases: Protocol

Provide an interface for aborting an uncommitted transaction.

__init__(*args, **kwargs)¶
class AppendRowsCall¶

Bases: Protocol

Provide an interface for appending rows to an existing transaction.

__init__(*args, **kwargs)¶
class CommitTransactionCall¶

Bases: Protocol

Provide an interface for committing a transaction.

__init__(*args, **kwargs)¶
class CreateTransactionCall¶

Bases: Protocol

Provide an interface for creating a new transaction.

__init__(*args, **kwargs)¶
class TransactionManager¶

Bases: contextlib.AbstractContextManager

Manage transactions in Benchling in a generic way across various implementations.

Implements a Python context manager, managing state for a Benchling transaction. Upon exit, the transaction manager will automatically attempt to commit the transaction. If an error is encountered, it will instead abort the transaction and re-raise the error.

__init__(create_transaction_call: CreateTransactionCall, commit_transaction_call: CommitTransactionCall, abort_transaction_call: AbortTransactionCall, append_row_call: AppendRowsCall)¶

Initialize TransactionManager.

Parameters
  • create_transaction_call – A function for creating a transaction

  • commit_transaction_call – A function for committing a transaction

  • abort_transaction_call – A function for aborting a transaction

  • append_row_call – A function for appending a row to an existing transaction

abort() → str¶

Abort the transaction in progress.

append(row: Any) → List[str]¶

Append a single row to an existing transaction and return the full list of pending rows.

commit() → str¶

Commit the transaction in progress.

extend(rows: Iterable[Any]) → List[str]¶

Append multiple rows to an existing transaction and return the full list of pending rows.