Utils
Classes:
|
If specified we want to _replace_ the default, but keep appending as a list? |
|
Note that we have to use this to prevent weird recursion issues. |
Functions:
|
Takes the given byte count and returns a nicely formatted string that includes the suffix (K/M/GB). |
|
Takes the given time in seconds and returns a nicely formatted string that includes the suffix. |
|
Prints output from running a command as it occurs. |
|
- class curifactory.experimental.utils.AppendReplaceAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)
If specified we want to _replace_ the default, but keep appending as a list?
- class curifactory.experimental.utils.FailsafeDict
- class curifactory.experimental.utils.PrefixedLogFactory(original_factory, prefix)
Note that we have to use this to prevent weird recursion issues.
My understanding is that since logging is in the global context, after many many tests, the old_factory keeps getting set to the previous new_factory, and you end up with a massive function chain. Using this class approach above, we can check if we’ve already set the factory to an instance of this class, and just update the prefix on it.
- curifactory.experimental.utils.human_readable_mem_usage(byte_count)
Takes the given byte count and returns a nicely formatted string that includes the suffix (K/M/GB).
- Parameters:
byte_count (int) – The number of bytes to convert into KB/MB/GB.
- Return type:
str
- curifactory.experimental.utils.human_readable_time(seconds)
Takes the given time in seconds and returns a nicely formatted string that includes the suffix.
- Parameters:
seconds (float) – The time in seconds to convert.
- Return type:
str
- curifactory.experimental.utils.init_graphviz_graph()
- curifactory.experimental.utils.run_command(cmd)
Prints output from running a command as it occurs.
- Parameters:
cmd (list[str]) – Either a string command or array of strings, as one would pass to
subprocess.run()
- curifactory.experimental.utils.set_logging_prefix(prefix)
- Parameters:
prefix (str)