quantlab.core.component.get_cls_from_path#
- quantlab.core.component.get_cls_from_path(path)[source]#
Import
path("pkg.module.ClassName") and return the class.- Parameters:
- pathstr
A dotted path whose last segment is the attribute to fetch.
- Returns:
- type
The attribute named by the final segment, normally a class.
- Raises:
- ModuleNotFoundError
If the module part cannot be imported. Configs written before a module was moved or renamed are not remapped to the new path.
- AttributeError
If the module has no such attribute.
Examples
>>> get_cls_from_path("quantlab.dataset.stock.StockDataset") <class 'quantlab.dataset.stock.StockDataset'>