def test_registered_subclass(self): """ Tests that registering Checkpointer subclasses works correctly. """ @Checkpointer.register("checkpointer_subclass") class CheckpointerSubclass(Checkpointer): def __init__(self, x: int, y: int) -> None: super().__init__() self.x = x self.y = y sub_inst = Checkpointer.from_params( Params({"type": "checkpointer_subclass", "x": 1, "y": 3}) ) assert sub_inst.__class__ == CheckpointerSubclass assert sub_inst.x == 1 and sub_inst.y == 3
def test_base_class_from_params(self): Checkpointer.from_params(Params({}), serialization_dir=self.TEST_DIR)
def test_base_class_from_params(self): Checkpointer.from_params(Params({}))