utils#
Module attributes and functions#
- utils.check_fn_dynamic_type(fn, tp, strict=True)[source]#
Controls if the function respects the type tp. The function must have the same number of arguments as the type tp and the same type for each argument.
- utils.create_if_not_exists(path)[source]#
Creates the specified folder if it does not exist.
- Parameters:
path (str) – the complete path of the folder to be created
- class utils.disable_logging(min_level=50)[source]#
Wrapper for disabling logging for a specific block of code.
- utils.field_with_aliases(choices)[source]#
Build a data type where for each key in choices there are a set of aliases.
Example
Given the following dictionary:
choices = { 'a': ['a', 'alpha'], 'b': ['b', 'beta'] }
The values ‘a’ and ‘alpha’ will be converted to ‘a’, and ‘b’ and ‘beta’ will be converted to ‘b’.
- utils.infer_args_from_signature(signature, excluded_signature=None)[source]#
Load the arguments of a function from its signature.
- utils.random_id(length=8, alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')[source]#
Returns a random string of the specified length.
- Parameters:
length – the length of the string
alphabet – the alphabet to be used
- Returns:
the random string
- utils.register_dynamic_module_fn(name, register, tp)[source]#
Register a dynamic module in the specified dictionary.