Ejemplo n.º 1
0
def test_model_name_is_set(test_output_dirs: OutputFolderForTests) -> None:
    container = DummyContainerWithModel()
    container.local_dataset = test_output_dirs.root_dir
    runner = MLRunner(model_config=None, container=container)
    runner.setup()
    expected_name = "DummyContainerWithModel"
    assert runner.container._model_name == expected_name
    assert expected_name in str(runner.container.outputs_folder)
Ejemplo n.º 2
0
 def _create_container(
         extra_local_dataset_paths: List[Path] = [],
         extra_azure_dataset_ids: List[str] = []) -> LightningContainer:
     container = DummyContainerWithModel()
     container.local_dataset = test_output_dirs.root_dir
     container.extra_local_dataset_paths = extra_local_dataset_paths  # type: ignore
     container.extra_azure_dataset_ids = extra_azure_dataset_ids
     runner = MLRunner(model_config=None, container=container)
     runner.setup()
     return runner.container
def test_regression_test(test_output_dirs: OutputFolderForTests) -> None:
    """
    Test that the file comparison for regression tests is actually called in the workflow.
    """
    container = DummyContainerWithModel()
    container.local_dataset = test_output_dirs.root_dir
    container.regression_test_folder = Path(str(uuid.uuid4().hex))
    runner = MLRunner(container=container)
    runner.setup()
    with pytest.raises(ValueError) as ex:
        runner.run()
    assert "Folder with expected files does not exist" in str(ex)
Ejemplo n.º 4
0
def test_optim_params2(test_output_dirs: OutputFolderForTests) -> None:
    """
    Test if the optimizer parameters are read correctly for containers.
    """
    container = DummyContainerWithModel()
    container.local_dataset = test_output_dirs.root_dir
    runner = MLRunner(model_config=None, container=container)
    runner.setup()
    lightning_model = runner.container.model
    optim, _ = lightning_model.configure_optimizers()
    expected_lr = 1e-1
    assert container.l_rate == expected_lr
    assert optim[0].param_groups[0]["lr"] == expected_lr