Reference

Core

class ActionTree.Action(execute, label)

The main class of ActionTree. An action to be started after all its dependencies are finished.

Parameters:
  • execute (callable) – the function to execute the action
  • label – whatever you want to attach to the action. Can be retrieved by label and get_preview().
status

The status of the action.

Possible values: Pending, Successful, Failed, Canceled.

Pending = 0

The initial status.

Successful = 1

The status after a successful execution.

Canceled = 2

The status after a failed execution where a dependency raised an exception.

Failed = 3

The status after a failed execution whre this action raised an exception.

label

The label passed to the constructor.

add_dependency(dependency)

Add a dependency to be executed before this action. Order of insertion of dependencies is not important.

Parameters:dependency (Action) –
dependencies

Return the list of this action’s dependencies.

get_preview()

Return the labels of this action and its dependencies, in an order that could be the execution order.

execute(jobs=1, keep_going=False)

Recursively execute this action’s dependencies then this action.

If dependencies raise exceptions, these exceptions are encapsulated in a CompoundException and thrown.

Parameters:
  • jobs (int) – number of actions to execute in parallel
  • keep_going (bool) – if True, then execution does not stop on first failure, but executes as many dependencies as possible.
begin_time

The local datetime at the begining of the execution of this action.

end_time

The local datetime at the end of the execution of this action.

exception ActionTree.CompoundException(exceptions)

Exception thrown by Action.execute() when a dependency raises an exception.

exceptions

The list of the encapsulated exceptions.

exception ActionTree.DependencyCycleException

Exception thrown by Action.add_dependency() when adding the new dependency would create a cycle.