[docs]@dataclasses.dataclassclassCorrectorSelector(CorrectorConfigABC):""" A dataclass containing all the information needed to build a CorrectorConfigABC, including the type of the CorrectorConfigABC and the data needed to build it. This is helpful as CorrectorSelector can be serialized and deserialized without any additional information, whereas to load a CorrectorConfigABC you would need to know the type of the CorrectorConfigABC being loaded. It is also convenient because CorrectorSelector is a single class that can be used to represent any CorrectorConfigABC, whereas CorrectorConfigABC is an ABC that can be implemented by many different classes. Parameters: type: the type of the CorrectorConfigABC config: data for a CorrectorConfigABC instance of the indicated type """type:strconfig:Mapping[str,Any]registry:ClassVar[Registry[CorrectorConfigABC]]=Registry[CorrectorConfigABC]()def__post_init__(self):super().__post_init__()ifself.corrector_disabled_epochs!=0:raiseValueError("corrector_disabled_epochs must be set on the wrapped corrector ""config (inside `config:`), not on the CorrectorSelector.")self._corrector_config_instance=self.registry.get(self.type,self.config)
[docs]@classmethoddefget_available_types(cls)->set[str]:"""This class method is used to expose all available types of Correctors."""returnset(cls.registry._types.keys())
def_get_corrector(self,dataset_info:DatasetInfo,)->CorrectorABC:# The wrapped config's get_corrector applies its own# corrector_disabled_epochs; the selector never schedules (guarded in# __post_init__), so no double-wrapping is possible.returnself._corrector_config_instance.get_corrector(dataset_info)