nipoppy.workflows.base¶
Workflow utilities.
Module Contents¶
- class nipoppy.workflows.base.BaseWorkflow(dpath_root, name, fpath_layout=None, logger=None, dry_run=False)¶
Bases:
nipoppy.base.Base,abc.ABCBase class with logging/subprocess utilities.
- Parameters:
dpath_root (nipoppy.env.StrOrPathLike)
name (str)
fpath_layout (Optional[nipoppy.env.StrOrPathLike])
logger (Optional[logging.Logger])
- log_prefix_run = '[RUN]'¶
- log_prefix_run_stderr = '[RUN STDERR]'¶
- log_prefix_run_stdout = '[RUN STDOUT]'¶
- path_sep = '-'¶
- pipeline_name = '[[NIPOPPY_PIPELINE_NAME]]'¶
- pipeline_version = '[[NIPOPPY_PIPELINE_VERSION]]'¶
- validate_layout = True¶
- config()¶
Load the configuration.
- Return type:
- copy(path_source, path_dest, log_level=logging.INFO, **kwargs)¶
Copy a file or directory.
- create_symlink(path_source, path_dest, log_level=logging.INFO, **kwargs)¶
Create a symlink to another path.
- dicom_dir_map()¶
Get the DICOM directory mapping.
- Return type:
- doughnut()¶
Load the doughnut.
- Return type:
- generate_fpath_log(dnames_parent=None, fname_stem=None)¶
Generate a log file path.
- Parameters:
- Return type:
- manifest()¶
Load the manifest.
- Return type:
- mkdir(dpath, log_level=logging.INFO, **kwargs)¶
Create a directory (by default including parents).
Do nothing if the directory already exists.
- rm(path, log_level=logging.INFO, **kwargs)¶
Remove a file or directory.
- run()¶
Run the workflow.
- run_cleanup()¶
Run the cleanup part of the workflow.
- run_command(command_or_args, check=True, **kwargs)¶
Run a command in a subprocess.
The command’s stdout and stderr outputs are written to the log with special prefixes.
If in “dry run” mode, the command is not executed, and the method returns the command string. Otherwise, the subprocess.Popen object is returned unless capture_output is True.
- Parameters:
- Return type:
- abstract run_main()¶
Run the main part of the workflow.
- run_setup()¶
Run the setup part of the workflow.
- save_tabular_file(tabular, fpath)¶
Save a tabular file.
- Parameters:
tabular (nipoppy.tabular.base.BaseTabular)
fpath (pathlib.Path)
- nipoppy.workflows.base.LOG_SUFFIX = '.log'¶