itwinai.utilsο
Utilities for itwinai package.
- itwinai.utils.load_yaml(path: str) Dict[source]ο
Load YAML file as dict.
- Parameters:
path (str) β path to YAML file.
- Raises:
yaml.YAMLError β for loading/parsing errors.
- Returns:
nested dict representation of parsed YAML file.
- Return type:
Dict
- itwinai.utils.dynamically_import_class(name: str) Type[source]ο
Dynamically import class by module path. Adapted from https://stackoverflow.com/a/547867
- Parameters:
name (str) β path to the class (e.g., mypackage.mymodule.MyClass)
- Returns:
class type.
- Return type:
__class__
- itwinai.utils.flatten_dict(d: MutableMapping, parent_key: str = '', sep: str = '.') MutableMapping[source]ο
Flatten dictionary
- Parameters:
d (MutableMapping) β nested dictionary to flatten
parent_key (str, optional) β prefix for all keys. Defaults to ββ.
sep (str, optional) β separator for nested key concatenation. Defaults to β.β.
- Returns:
flattened dictionary with new keys.
- Return type:
MutableMapping
- class itwinai.utils.SignatureInspector(func: Callable)[source]ο
Bases:
objectProvides the functionalities to inspect the signature of a function or a method.
- Parameters:
func (Callable) β function to be inspected.
- INFTY: int = 9223372036854775807ο
- property has_varargs: boolο
Checks if the function has
*argsparameter.
- property has_kwargs: boolο
Checks if the function has
**kwargsparameter.
- property required_params: Tuple[str]ο
Names of required parameters. Class methodβs βselfβ is skipped.
- property min_params_num: intο
Minimum number of arguments required.
- property max_params_num: intο
Max number of supported input arguments. If no limit,
SignatureInspector.INFTYis returned.