crandas.transactions#
- exception crandas.transactions.DirectlyAccessingDeferredObjectError#
Bases:
Exception
Exception when accessing a deferred object outside a transaction
Operations performed inside a transaction return “deferred” objects (e.g., a CDataFrame that is an instance of Deferred). Such deferred objects can be used inside the transaction but not outside it. When the transaction has completed, the resulting object is stored as the .result field of the deferred object. Outside of the object, this result field should be used. If the deferred object is used instead, this exception is raised.
- class crandas.transactions.ResponseHandlerList(**kwargs)#
Bases:
ResponseHandler
,Deferred
- class crandas.transactions.Transaction(name=None, mode=None, add_nonce=False, bitlength=None, print_json=None, authorization_file=None, dry_run=None, **kwargs)#
Bases:
object
Transaction context manager (see https://docs.python.org/3/reference/datamodel.html#context-managers)
Commands executed in this context are accumulated and executed as a single unit when the context is exited.
Within the Transaction, VDL operations (e.g., crandas.merge) return a DeferredObject instance. After the Transaction, the result of the operation can be accessed via the .result field of the DeferredObject.
NOTE: When using Transaction internally for substeps of a larger operation, all but the last commands inside the Transaction should run in deferred mode (vdl_query(…, mode=”defer”)). This way, the outputs of these transactions do not leak information regardless of what happens to the output of the overall operation.
- __enter__()#
Enter the transaction block
- __exit__(exc_type, exc_value, traceback)#
Exit the runtime context related to this object. The parameters describe the exception that led to the context being exited.
- add(json_query, expected)#
Called by vdl_query to add the command-to-be-executed to the transaction
- Parameters:
json_query ((JSON-serializable) str) – VDL command
expected (ExpectedObject) – expected value for json_query
- crandas.transactions.end_transaction()#
Ends the current (innermost) transaction
- crandas.transactions.get_current_transaction()#
Returns the current (innermost) transaction instance
- crandas.transactions.show_transaction_graph(t, outfile)#
Generates a transaction graph
- Parameters:
t (Transaction) – the Transaction to be graphed
outfile (str) – name of the output file
- crandas.transactions.start_transaction()#
Start a new transaction