nemo_automodel.components.utils.yaml_utils
nemo_automodel.components.utils.yaml_utils
Module Contents
Functions
API
Return <module>.<qualname> for a class or function.
Raises:
AttributeError: Ifobjhas no__qualname__or is not defined in an imported module._safe_object_representerrelies on this to fall back to the object’s class.
Represent enums in YAML.
Represent functions in YAML.
Represent transformers GenerationConfig objects in YAML.
Represent functools.partial objects in YAML.
General object representer for YAML.
This function is a fallback for objects that don’t have specific representers. If the object has qualname attr, the target is set to f”{inspect.getmodule(obj).name}.{obj.qualname}”. If the object does not have a qualname attr, the target is set from its class attr. The call key is used to indicate whether the target should be called to create an instance.
Parameters:
The YAML dumper to use for serialization.
The object to serialize.
Returns: yaml.Node
The YAML representation of the data.
Represent torch dtypes in YAML.
Context manager for safely adding and removing custom YAML representers.
Temporarily adds custom representers for functions, classes, and other objects to the YAML SafeDumper, and restores the original representers when exiting the context.
Usage: with safe_yaml_representers(): yaml_str = yaml.safe_dump(my_complex_object)