Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.
brainprep.decorators.CommandLineWrapperHook¶
- class brainprep.decorators.CommandLineWrapperHook[source]¶
Bases:
HookPerform command line wrapper-specific preprocessing and output validation.
This Hook provides two core features:
Execute command-line operations in normal (non-dry run) mode.
Recursively validates all generated output files.
Examples
>>> from brainprep.decorators import step, CommandLineWrapperHook >>> from brainprep.config import Config
>>> @step( ... hooks=[CommandLineWrapperHook()] ... ) ... def ls_command(my_dir): ... return ["ls", my_dir]
>>> with Config(dryrun=True): ... ls_command("/tmp") [command] - ls /tmp
- after_call(outputs)[source]¶
Transform and inspect outputs after the function call.
This method executes command-line operations in normal (non-dry run) mode, inspects the output returned by the decorated function, recursively validates each file path, and normalizes the return type:
Noneis returned unchanged.A single-file output is returned as a
File.Multiple files are returned as a
tuple[File].
- Parameters:
- outputsFile | tuple[File] | None
The output file or tuple of files returned by the decorated function, or
Noneif no output was produced.
- Returns:
- outputsFile | tuple[File] | None
The validated output.
- Raises:
- ValueError
If the decorated function does not return a valid command specification.