Ejemplo n.º 1
0
 def __init__(
     self,
     optim1: dict,
     optim2: dict,
     scheduler: dict,
 ):
     super().__init__()
     self.optim1 = instantiate_class(self.parameters(), optim1)
     self.optim2 = instantiate_class(self.parameters(), optim2)
     self.scheduler = instantiate_class(self.optim1, scheduler)
def test_lightningCLI_old_module_deprecation():
    with pytest.deprecated_call(
            match=r"LightningCLI.*deprecated in v1.7.*Use the equivalent class"
    ):
        with mock.patch("sys.argv", ["any.py"]):
            old_cli.LightningCLI(BoringModel, run=False)

    with pytest.deprecated_call(
            match=
            r"SaveConfigCallback.*deprecated in v1.7.*Use the equivalent class"
    ):
        old_cli.SaveConfigCallback(Mock(), Mock(), Mock())

    with pytest.deprecated_call(
            match=
            r"LightningArgumentParser.*deprecated in v1.7.*Use the equivalent class"
    ):
        old_cli.LightningArgumentParser()

    with pytest.deprecated_call(
            match=
            r"instantiate_class.*deprecated in v1.7.*Use the equivalent function"
    ):
        assert isinstance(
            old_cli.instantiate_class(
                tuple(), {"class_path": "pytorch_lightning.Trainer"}), Trainer)