gigl.experimental.knowledge_graph_embedding.lib.config.hydra_utils#
Functions#
| Builds a Hydra-compatible dictionary from a dataclass or namedtuple. | |
| 
 | Returns the fully qualified name (module.ClassName) for a class or object. | 
Module Contents#
- gigl.experimental.knowledge_graph_embedding.lib.config.hydra_utils.build_hydra_dict_from_object(obj)[source]#
- Builds a Hydra-compatible dictionary from a dataclass or namedtuple. - Recursively processes object attributes and adds ‘_target_’ fields for Hydra instantiation. Handles nested structures, lists, and various Python types. Autonomously converts NewType instances to their base string representation. - Parameters:
- obj (Any) – The object to convert. Can be a dataclass, namedtuple, list, enum, or primitive type (str, int, float, bool, None). 
- Returns:
- A dictionary (for complex objects) or the original value (for primitives)
- that can be used in Hydra configuration files. Complex objects include a ‘_target_’ field pointing to their fully qualified class name. 
 
- Return type:
- Any 
 
- gigl.experimental.knowledge_graph_embedding.lib.config.hydra_utils.get_fully_qualified_name(cls_or_obj)[source]#
- Returns the fully qualified name (module.ClassName) for a class or object. - Handles both classes and instances by getting the type of the instance. This is useful for generating Hydra _target_ paths for dynamic instantiation. - Parameters:
- cls_or_obj (Union[Type, Any]) – Either a class type or an instance of a class. 
- Returns:
- The fully qualified name in the format “module.ClassName”. 
- Return type:
- str 
 
