aria.orchestrator.workflows.api
¶
Workflow API.
aria.orchestrator.workflows.api.task_graph
¶
Task graph.
-
class
aria.orchestrator.workflows.api.task_graph.
TaskGraph
(name)¶ Bases:
object
Task graph builder.
-
add_dependency
(dependent, dependency)¶ Adds a dependency for one item (task, sequence or parallel) on another.
The dependent will only be executed after the dependency terminates. If either of the items is either a sequence or a parallel, multiple dependencies may be added.
Parameters: - dependent – dependent (task, sequence or parallel)
- dependency – dependency (task, sequence or parallel)
Returns: True
if the dependency between the two hadn’t already existed, otherwiseFalse
Return type: Raises: TaskNotInGraphError – if either the dependent or dependency are tasks which are not in the graph
-
add_tasks
(task, *tasks, **kwargs)¶
-
get_dependencies
(dependent_task)¶ Iterates over the task’s dependencies.
Parameters: dependent_task – task whose dependencies are requested Raises: TaskNotInGraphError – if dependent_task
is not in the graph
-
get_dependents
(dependency_task)¶ Iterates over the task’s dependents.
Parameters: dependency_task – task whose dependents are requested Raises: TaskNotInGraphError – if dependency_task
is not in the graph
-
get_task
(task_id)¶ Get a task instance that’s been inserted to the graph by the task’s ID.
Parameters: task_id (basestring) – task ID Raises: TaskNotInGraphError – if no task found in the graph with the given ID
-
has_dependency
(dependent, dependency)¶ Checks whether one item (task, sequence or parallel) depends on another.
Note that if either of the items is either a sequence or a parallel, and some of the dependencies exist in the graph but not all of them, this method will return
False
.Parameters: - dependent – dependent (task, sequence or parallel)
- dependency – dependency (task, sequence or parallel)
Returns: True
if the dependency between the two exists, otherwiseFalse
Return type: Raises: TaskNotInGraphError – if either the dependent or dependency are tasks which are not in the graph
-
has_tasks
(task, *tasks, **kwargs)¶
-
id
¶ ID of the graph
-
remove_dependency
(dependent, dependency)¶ Removes a dependency for one item (task, sequence or parallel) on another.
Note that if either of the items is either a sequence or a parallel, and some of the dependencies exist in the graph but not all of them, this method will not remove any of the dependencies and return
False
.Parameters: - dependent – dependent (task, sequence or parallel)
- dependency – dependency (task, sequence or parallel)
Returns: False
if the dependency between the two hadn’t existed, otherwiseTrue
Return type: Raises: TaskNotInGraphError – if either the dependent or dependency are tasks which are not in the graph
-
remove_tasks
(task, *tasks, **kwargs)¶
-
sequence
(task, *tasks, **kwargs)¶
-
tasks
¶ Iterator over tasks in the graph.
-
topological_order
(reverse=False)¶ Topological sort of the graph.
Parameters: reverse – whether to reverse the sort Returns: list which represents the topological sort
-
-
exception
aria.orchestrator.workflows.api.task_graph.
TaskNotInGraphError
¶ Bases:
exceptions.Exception
An error representing a scenario where a given task is not in the graph as expected.
aria.orchestrator.workflows.api.task
¶
Provides the tasks to be entered into the task graph
-
class
aria.orchestrator.workflows.api.task.
BaseTask
(ctx=None, **kwargs)¶ Bases:
object
Base class for tasks.
-
id
¶ UUID4 ID.
-
workflow_context
¶ Context of the current workflow.
-
-
class
aria.orchestrator.workflows.api.task.
OperationTask
(actor, interface_name, operation_name, arguments=None, ignore_failure=None, max_attempts=None, retry_interval=None)¶ Bases:
aria.orchestrator.workflows.api.task.BaseTask
Executes an operation.
Variables: - name (basestring) – formatted name (includes actor type, actor name, and interface/operation names)
- actor (
Node
orRelationship
) – node or relationship - interface_name (basestring) – interface name on actor
- operation_name (basestring) – operation name on interface
- plugin (
Plugin
) – plugin (or None for default plugin) - function (basestring) – path to Python function
- arguments ({
basestring
:Argument
}) – arguments to send to Python function - ignore_failure (bool) – whether to ignore failures
- max_attempts (int) – maximum number of attempts allowed in case of failure
- retry_interval (float) – interval between retries (in seconds)
Parameters: - actor (
Node
orRelationship
) – node or relationship - interface_name (basestring) – interface name on actor
- operation_name (basestring) – operation name on interface
- arguments ({
basestring
: object}) – override argument values - ignore_failure (bool) – override whether to ignore failures
- max_attempts (int) – override maximum number of attempts allowed in case of failure
- retry_interval (float) – override interval between retries (in seconds)
Raises: OperationNotFoundException – if
interface_name
andoperation_name
do not refer to an operation on the actor-
NAME_FORMAT
= ‘{interface}:{operation}@{type}:{name}’¶
-
class
aria.orchestrator.workflows.api.task.
StubTask
(ctx=None, **kwargs)¶ Bases:
aria.orchestrator.workflows.api.task.BaseTask
Enables creating empty tasks.
-
class
aria.orchestrator.workflows.api.task.
WorkflowTask
(workflow_func, **kwargs)¶ Bases:
aria.orchestrator.workflows.api.task.BaseTask
Executes a complete workflow.
Parameters: - workflow_func – function to run
- kwargs – kwargs that would be passed to the workflow_func
-
graph
¶ Graph constructed by the sub workflow.
-
aria.orchestrator.workflows.api.task.
create_relationship_tasks
(relationship, interface_name, source_operation_name=None, target_operation_name=None, **kwargs)¶ Creates a relationship task (source and target).
Parameters: - relationship – relationship instance itself
- source_operation_name –
- target_operation_name –
-
aria.orchestrator.workflows.api.task.
create_relationships_tasks
(node, interface_name, source_operation_name=None, target_operation_name=None, **kwargs)¶ Creates a relationship task (source and target) for all of a node relationships.
Parameters: - source_operation_name (basestring) – relationship operation name
- interface_name (basestring) – name of the interface
- source_operation_name –
- target_operation_name –
- node – source node
-
aria.orchestrator.workflows.api.task.
create_task
(actor, interface_name, operation_name, **kwargs)¶ Helper function that enables safe creation of
OperationTask
. If the supplied interface or operation do not exist,None
is returned.Parameters: - actor – actor for this task
- interface_name – name of the interface
- operation_name – name of the operation
- kwargs – any additional kwargs to be passed to the OperationTask
Returns: OperationTask or None (if the interface/operation does not exists)
-
aria.orchestrator.workflows.api.task.
has_operation
(actor, interface_name, operation_name)¶