nipoppy.workflows.base.BaseWorkflow

class nipoppy.workflows.base.BaseWorkflow(name, verbose=False, dry_run=False)

Base workflow class with logging/subprocess/filesystem utilities.

Parameters:
copy_template(path_source, path_dest, **template_kwargs)

Copy a file with template substitution.

Parameters:
  • path_source – Source template file path

  • path_dest – Destination file path

  • **template_kwargs – Keyword arguments passed to process_template_str for substitution

log_command(command)

Write a command to the log with a special prefix.

Parameters:

command (str)

run()

Run the workflow.

run_cleanup()

Run the cleanup part of the workflow.

run_command(command_or_args, check=True, quiet=False, **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:
  • command_or_args (Sequence[str] | str) – The command to run.

  • check (bool, optional) – If True, raise an error if the process exits with a non-zero code, by default True

  • quiet (bool, optional) – If True, do not log the command, by default False

  • **kwargs – Passed to subprocess.Popen.

Return type:

subprocess.Popen or str

abstractmethod 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:
dry_run = False
log_prefix_run = '[RUN]'
log_prefix_run_stderr = '[RUN STDERR]'
log_prefix_run_stdout = '[RUN STDOUT]'
name
return_code
verbose = False