transactions
prefect.transactions
Functions
get_transaction
↗
transaction
↗
A context manager for opening and managing a transaction.
Args:
-
: An identifier to use for the transaction-
: The store to use for persisting the transaction result. If not provided, a default store will be used based on the current run context.-
: The commit mode controlling when the transaction and child transactions are committed-
: Whether to overwrite an existing transaction record in the store-
: Whether to write the result to the store on commit. If not provided, will default will be determined by the current run context. If no run context is available, the value ofPREFECT_RESULTS_PERSIST_BY_DEFAULT
will be used.
Classes
IsolationLevel
↗
CommitMode
↗
TransactionState
↗
BaseTransaction
↗
A base model for transaction state.
Methods:
set
↗
Set a stored value in the transaction.
Args:
name
: The name of the value to setvalue
: The value to set
Examples:
Set a value for use later in the transaction:
get
↗
Get a stored value from the transaction.
Child transactions will return values from their parents unless a value with the same name is set in the child transaction.
Direct changes to returned values will not update the stored value. To update the
stored value, use the set
method.
Args:
name
: The name of the value to getdefault
: The default value to return if the value is not found
Returns:
- The value from the transaction
Examples:
Get a value from the transaction:
Get a value from a parent transaction:
Update a stored value:
is_committed
↗
is_rolled_back
↗
is_staged
↗
is_pending
↗
is_active
↗
prepare_transaction
↗
Helper method to prepare transaction state and validate configuration.
add_child
↗
get_parent
↗
stage
↗
Stage a value to be committed later.
get_active
↗
Transaction
↗
A model representing the state of a transaction.
Methods:
begin
↗
read
↗
reset
↗
commit
↗
run_hook
↗
rollback
↗
AsyncTransaction
↗
A model representing the state of an asynchronous transaction.