record
record(
out_fn,
func,
return_results=False,
log_fn=None,
rerun_hours=48,
verbose=True,
rerun=False,
)Run the function and save the returned output to file.
This function takes a function func as input and outputs a wrapped function wrapped_func. wrapped_func is similar to func, except that it will also save the returned output of func to files (file names indicated by out_fn), so that it can be accessed later.
Runs use .started and .completed markers.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| out_fn | str or list/tuple of str | The names of the output file(s). | required |
| func | function | The function to be wrapped. | required |
| return_results | bool | Whether wrapped_func will return the output of the original function func. If it’s False, None will be returned. |
False |
| log_fn | (str, None) | The root file name of the text files for logging. | str |
| rerun_hours | int | Rerun the function if the start of the last run was more than rerun_hours ago. |
48 |
| verbose | bool | Whether to output additional logging information. | True |
| rerun | bool | Whether to rerun the function even if the output files exist, overriding existing start markers as well. | False |
Returns
| Name | Type | Description |
|---|---|---|
| wrapped_func | function | The wrapped function that will run func and save the results to out_fn. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | Raised when out_fn is neither a string or a tuple/list of strings. |