protomotions.utils.hydra_replacement module¶
Simple replacement for hydra.utils functions to avoid the heavy hydra-core dependency. Provides get_class and instantiate functions with compatible APIs.
- protomotions.utils.hydra_replacement.get_class(path)[source]¶
Import and return a class from a string path.
- Parameters:
path (str) – Fully qualified class path, e.g., “torch.optim.Adam”
- Returns:
The class object
- Return type:
Example
>>> Adam = get_class("torch.optim.Adam") >>> optimizer = Adam(params, lr=0.001)
- protomotions.utils.hydra_replacement.instantiate(config, **kwargs)[source]¶
Instantiate a class from a config object.
- Parameters:
config – Config object with _target_ attribute specifying the class path, or a dict with ‘_target_’ key
**kwargs – Additional keyword arguments to pass to the constructor, overriding config values
- Returns:
Instance of the specified class
- Return type:
Example
>>> class Config: ... _target_ = "torch.optim.Adam" ... lr = 0.001 >>> optimizer = instantiate(config, params=model.parameters())