iota2.common.utils
This module contains decorators and utils functions.
Functions
|
Yield an iterator, splitting the input list by chunks of given size |
|
Add dunder methods based on the fields defined in the class. |
|
Return a tuple describing the fields of this dataclass. |
|
Returns True if obj is a dataclass or an instance of a dataclass. |
|
Check if at least one field of the dataclass is set. |
|
Try to convert labels to int. |
|
Decorator to print types of arguments when calling a function. |
|
Launch a system command and raise an execption if fail. |
|
Convert a string vue to boolean. |
|
perf_counter() -> float |
|
Decorator factory to apply update_wrapper() to a wrapper function |
Classes
|
Special type indicating an unconstrained type. |
|
|
|
|
|
A Mapping is a generic container for associating key/value pairs. |
|
Remove element decorator to remove strings in a list. |
|
Dataclass containing ressources for tasks |
- class iota2.common.utils.RemoveInStringList(*args)[source]
Remove element decorator to remove strings in a list.
- class iota2.common.utils.TaskConfig(logger=<Logger distributed.worker (WARNING)>, ram=128)[source]
Dataclass containing ressources for tasks
- __init__(logger=<Logger distributed.worker (WARNING)>, ram=128)
-
logger:
Logger= <Logger distributed.worker (WARNING)>
-
ram:
int= 128
- iota2.common.utils.chunker(list_of_things, chunk_size)[source]
Yield an iterator, splitting the input list by chunks of given size
- Parameters:
list_of_things (
list) – Input listchunk_size (
int) – Number of elements by list
- Return type:
Generator
- iota2.common.utils.is_empty_dataclass(dataclass_inst)[source]
Check if at least one field of the dataclass is set.
- Return type:
bool
- iota2.common.utils.is_nomenclature_castable_to_int(labels_table)[source]
Try to convert labels to int.
- Return type:
bool
- iota2.common.utils.print_types(func)[source]
Decorator to print types of arguments when calling a function.
- Return type:
Callable
- iota2.common.utils.run(cmd, desc=None, env=None, logger=<Logger distributed.worker (WARNING)>)[source]
Launch a system command and raise an execption if fail.
- Parameters:
cmd (
str) – the system command to be launcheddesc (
Optional[str]) – an optional description of the command for log_direnv (
Optional[Mapping[str,str]]) – the environ variable if None, os.environ is usedlogger (
Logger) – by default module LOGGER value is used
- Return type:
int