Library API (application programmer interface)
The Pydra workflow engine.
Pydra is a rewrite of the Nipype engine with mapping and joining as first-class operations. It forms the core of the Nipype 2.0 ecosystem.
- class pydra.AuditFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Flag
Auditing flags.
- ALL = 3
Track provenance and resource utilization.
- NONE = 0
Do not track provenance or monitor resources.
- PROV = 1
Track provenance only.
- RESOURCE = 2
Monitor resource utilization only.
- class pydra.ShellCommandTask(audit_flags: ~pydra.utils.messenger.AuditFlag = AuditFlag.NONE, cache_dir=None, input_spec: ~pydra.engine.specs.SpecInfo | None = None, cont_dim=None, messenger_args=None, messengers=None, name=None, output_spec: ~pydra.engine.specs.SpecInfo | None = None, rerun=False, strip=False, environment=<pydra.engine.environments.Native object>, **kwargs)
Bases:
TaskBase
Wrap a shell command as a task element.
- DEFAULT_COPY_COLLATION = 2
- property cmdline
Get the actual command line that will be submitted Returns a list if the task has a state.
- command_args(root=None)
Get command line arguments
- get_bindings(root: str | None = None) dict[str, tuple[str, str]]
Return bindings necessary to run task in an alternative root.
This is primarily intended for contexts when a task is going to be run in a container with mounted volumes.
- Parameters:
root (str)
- Returns:
bindings – Mapping from paths in the host environment to the target environment
- Return type:
- input_spec = None
- output_spec = None
- class pydra.Submitter(plugin: str | Type[Worker] = 'cf', **kwargs)
Bases:
object
Send a task to the execution backend.
- close()
Close submitter.
Do not close previously running loop.
- async expand_runnable(runnable, wait=False, rerun=False)
This coroutine handles state expansion.
Removes any states from runnable. If wait is set to False (default), aggregates all worker execution coroutines and returns them. If wait is True, waits for all coroutines to complete / error and returns None.
- async expand_workflow(wf, rerun=False)
Expand and execute a stateless
Workflow
. This method is only reached by Workflow._run_task.- Parameters:
wf (
Workflow
) – Workflow Task object- Returns:
wf – The computed workflow
- Return type:
- async submit_from_call(runnable, rerun, environment)
This coroutine should only be called once per Submitter call, and serves as the bridge between sync/async lands.
There are 4 potential paths based on the type of runnable: 0) Workflow has a different plugin than a submitter 1) Workflow without State 2) Task without State 3) (Workflow or Task) with State
Once Python 3.10 is the minimum, this should probably be refactored into using structural pattern matching.
- class pydra.Workflow(name, audit_flags: AuditFlag = AuditFlag.NONE, cache_dir=None, cache_locations=None, input_spec: List[str] | Dict[str, Type[Any]] | SpecInfo | None = None, cont_dim=None, messenger_args=None, messengers=None, output_spec: List[str] | Dict[str, type] | SpecInfo | BaseSpec | None = None, rerun=False, propagate_rerun=True, **kwargs)
Bases:
TaskBase
A composite task with structure of computational graph.
- add(task)
Add a task to the workflow.
- Parameters:
task (
TaskBase
) – The task to be added.
- property checksum
Calculates the unique checksum of the task. Used to create specific directory name for task that are run; and to create nodes checksums needed for graph checksums (before the tasks have inputs etc.)
- create_connections(task, detailed=False)
Add and connect a particular task to existing nodes in the workflow.
- Parameters:
task (
TaskBase
) – The task to be added.detailed (
bool
) – If True, add_edges_description is run for self.graph to add a detailed descriptions of the connections (input/output fields names)
- create_dotfile(type='simple', export=None, name=None, output_dir=None)
creating a graph - dotfile and optionally exporting to other formats
- property graph_sorted
Get a sorted graph representation of the workflow.
- property lzin
- property nodes
Get the list of node names.
- set_output(connections: Tuple[str, LazyField] | List[Tuple[str, LazyField]])
Set outputs of the workflow by linking them with lazy outputs of tasks
- Parameters:
connections (tuple[str, LazyField] or list[tuple[str, LazyField]] or None) – single or list of tuples linking the name of the output to a lazy output of a task in the workflow.
Subpackages
- pydra.engine package
AuditFlag
ShellCommandTask
Submitter
Workflow
- Submodules
- pydra.engine.audit module
- pydra.engine.boutiques module
- pydra.engine.core module
TaskBase
TaskBase.DEFAULT_COPY_COLLATION
TaskBase.SUPPORTED_COPY_MODES
TaskBase.audit_flags
TaskBase.cache_dir
TaskBase.cache_locations
TaskBase.can_resume
TaskBase.checksum
TaskBase.checksum_states()
TaskBase.combine()
TaskBase.cont_dim
TaskBase.done
TaskBase.errored
TaskBase.generated_output_names
TaskBase.get_input_el()
TaskBase.help()
TaskBase.lzout
TaskBase.output_dir
TaskBase.output_names
TaskBase.pickle_task()
TaskBase.result()
TaskBase.set_state()
TaskBase.split()
TaskBase.uid
TaskBase.version
Workflow
is_lazy()
is_task()
is_workflow()
- pydra.engine.environments module
- pydra.engine.graph module
DiGraph
DiGraph.add_edges()
DiGraph.add_edges_description()
DiGraph.add_nodes()
DiGraph.calculate_max_paths()
DiGraph.copy()
DiGraph.create_dotfile_detailed()
DiGraph.create_dotfile_nested()
DiGraph.create_dotfile_simple()
DiGraph.edges
DiGraph.edges_names
DiGraph.export_graph()
DiGraph.nodes
DiGraph.nodes_details
DiGraph.nodes_names_map
DiGraph.remove_nodes()
DiGraph.remove_nodes_connections()
DiGraph.remove_previous_connections()
DiGraph.remove_successors_nodes()
DiGraph.sorted_nodes
DiGraph.sorted_nodes_names
DiGraph.sorting()
- pydra.engine.helpers module
PydraFileLock
allowed_values_validator()
argstr_formatting()
copyfile_workflow()
create_checksum()
ensure_list()
execute()
from_list_if_single()
gather_runtime_info()
get_available_cpus()
get_open_loop()
load_and_run()
load_and_run_async()
load_result()
load_task()
make_klass()
output_from_inputfields()
parse_copyfile()
parse_format_string()
position_sort()
print_help()
read_and_display()
read_and_display_async()
read_stream_and_display()
record_error()
save()
- pydra.engine.helpers_file module
- pydra.engine.helpers_state module
- pydra.engine.run_pickled module
- pydra.engine.specs module
- pydra.engine.state module
State
State.name
State.splitter
State.splitter_rpn_compact
State.splitter_rpn
State.combiner
State.splitter_final
State.other_states
State.inner_inputs
State.states_ind
State.states_val
State.inputs_ind
State.group_for_inputs
State.group_for_inputs_final
State.groups_stack_final
State.final_combined_ind_mapping
State.combiner
State.combiner_validation()
State.current_combiner
State.current_combiner_all
State.current_splitter
State.current_splitter_rpn
State.inner_inputs
State.other_states
State.prepare_inputs()
State.prepare_states()
State.prepare_states_combined_ind()
State.prepare_states_ind()
State.prepare_states_val()
State.prev_state_combiner
State.prev_state_combiner_all
State.prev_state_splitter
State.prev_state_splitter_rpn
State.prev_state_splitter_rpn_compact
State.set_input_groups()
State.splits()
State.splitter
State.splitter_final
State.splitter_rpn
State.splitter_rpn_compact
State.splitter_rpn_final
State.splitter_validation()
State.update_connections()
- pydra.engine.submitter module
- pydra.engine.task module
- pydra.engine.workers module
- pydra.mark package
- pydra.tasks package
- pydra.utils package
- Submodules
- pydra.utils.hash module
- pydra.utils.messenger module
- pydra.utils.misc module
- pydra.utils.profiler module
- pydra.utils.typing module
TypeParser
TypeParser.COERCIBLE_DEFAULT
TypeParser.NOT_COERCIBLE_DEFAULT
TypeParser.apply_to_instances()
TypeParser.check_coercible()
TypeParser.check_type()
TypeParser.check_type_coercible()
TypeParser.coerce()
TypeParser.coercible
TypeParser.contains_type()
TypeParser.get_args()
TypeParser.get_item_type()
TypeParser.get_origin()
TypeParser.is_instance()
TypeParser.is_subclass()
TypeParser.label
TypeParser.label_str
TypeParser.match_any_of_union
TypeParser.matches()
TypeParser.matches_type()
TypeParser.not_coercible
TypeParser.strip_splits()
TypeParser.superclass_auto_cast
TypeParser.tp
- Submodules