logging
Utility functions for logging.
Functions
Decorator to prevent interleaved output in distributed/multi-threaded environments. |
|
Capture stdout and stderr within the invoked context. |
|
Silences stdout within the invoked context. |
|
Convert big floating number to human readable string. |
|
Prints only on the master process. |
|
Silences warnings that match a given pattern. |
|
Issues a warning only on the master process. |
- exception DeprecatedError
Bases:
NotImplementedErrorError for deprecated functions.
- atomic_print(func)
Decorator to prevent interleaved output in distributed/multi-threaded environments.
- capture_io(capture_stderr=True)
Capture stdout and stderr within the invoked context.
- Parameters:
capture_stderr (bool) – Whether to capture stderr. Defaults to True.
- Returns:
An iterator that yields a StringIO object that contains the captured output.
- Return type:
Iterator[StringIO]
Example:
with capture_io() as buf: print("Hello, world!") print(buf.getvalue())
- no_stdout()
Silences stdout within the invoked context.
- num2hrb(num, suffix='')
Convert big floating number to human readable string.
- Parameters:
num (float)
- Return type:
str
- print_rank_0(*args, **kwargs)
Prints only on the master process.
- silence_matched_warnings(pattern=None)
Silences warnings that match a given pattern.
- Parameters:
pattern (str) – The pattern to match against warning messages. Defaults to None.
- warn_rank_0(message, *args, **kwargs)
Issues a warning only on the master process.