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.SaveRuntimeHook¶
- class brainprep.decorators.SaveRuntimeHook(parent=False)[source]¶
Bases:
HookDecorator that save logged runtime metadata in a ‘output_dir/log’ folder.
- Parameters:
- parentbool
If True, logs will be saved in the parent output directory instead of the output directory. This is useful when centralizing log files. Default False.
Examples
>>> from brainprep.decorators import ( ... step, LogRuntimeHook, SaveRuntimeHook ... )
>>> @step( ... hooks=[ ... LogRuntimeHook(), ... SaveRuntimeHook(), ... ] ... ) ... def add(a, b, output_dir="/tmp"): ... '''Adds two numbers.''' ... return a + b
>>> result = add(3, 5)
- before_call(func, inputs)[source]¶
Transform and inspect inputs before the function call.
- Parameters:
- funcCallable
The function to be decorated.
- inputsdict[str, Any]
Positional and keyword arguments passed to func. If a report_file keyword argument is passed, the logged runtime metada are saved in this file.
- Returns:
- inputsdict[str, Any]
Positional and keyword arguments passed to func (unchanged).
- Raises:
- ValueError
If the output_dir keyword argument is not defined.