MolecularDiffusion.utils.pretty¶
Attributes¶
Classes¶
Handle pretty printing operations onto a stream using a set of |
Functions¶
|
Format a python object as a string. |
|
Format an array as a string. |
|
Print a python object to a stream. |
|
Optional decorator that controls the failure behavior when executing the task function. |
|
Format time as a string. |
Module Contents¶
- class MolecularDiffusion.utils.pretty.PrettyPrinter(indent=1, width=80, depth=None, stream=None, *, compact=False, sort_dicts=True, underscore_numbers=False)¶
Bases:
pprint.PrettyPrinterHandle pretty printing operations onto a stream using a set of configured parameters.
- indent
Number of spaces to indent for each level of nesting.
- width
Attempted maximum number of columns in the output.
- depth
The maximum depth to print out nested structures.
- stream
The desired output stream. If omitted (or false), the standard output stream available at construction will be used.
- compact
If true, several items will be combined in one line.
- sort_dicts
If true, dict keys are sorted.
- underscore_numbers
If true, digit groups are separated with underscores.
- display = 3¶
- truncation = 10¶
- MolecularDiffusion.utils.pretty.format(object, *args, **kwargs)¶
Format a python object as a string.
- MolecularDiffusion.utils.pretty.long_array(array, truncation=10, display=3)¶
Format an array as a string.
- MolecularDiffusion.utils.pretty.print(object, *args, **kwargs)¶
Print a python object to a stream.
- MolecularDiffusion.utils.pretty.task_wrapper(task_func: Callable) Callable¶
Optional decorator that controls the failure behavior when executing the task function.
- This wrapper can be used to:
make sure loggers are closed even if the task function raises an exception (prevents multirun failure)
save the exception to a .log file
mark the run as failed with a dedicated file in the logs/ folder (so we can find and rerun it later)
etc. (adjust depending on your needs)
Example: ``` @utils.task_wrapper def train(cfg: DictConfig) -> Tuple[Dict[str, Any], Dict[str, Any]]:
… return metric_dict, object_dict
- Parameters:
task_func – The task function to be wrapped.
- Returns:
The wrapped task function.
- MolecularDiffusion.utils.pretty.time(seconds)¶
Format time as a string.
- Parameters:
seconds (float) – time in seconds
- MolecularDiffusion.utils.pretty.ellipsis¶
- MolecularDiffusion.utils.pretty.line = '------------------------------'¶
- MolecularDiffusion.utils.pretty.log¶
- MolecularDiffusion.utils.pretty.separator = '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'¶