diff --git a/requirements/base.txt b/requirements/base.txt index c616ad8c38a..7cd37e41b72 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -10,4 +10,4 @@ scipy>=1.8 bayesian-optimization>=1.2.0 tensorboard>=2.11.0 multiprocess -pynvml +pynvml>=11.0.0 diff --git a/src/otx/cli/utils/experiment.py b/src/otx/cli/utils/experiment.py index 61abc77d1f0..cc4af013f80 100644 --- a/src/otx/cli/utils/experiment.py +++ b/src/otx/cli/utils/experiment.py @@ -97,7 +97,7 @@ def _check_resource(queue: mp.Queue, resource_types: Optional[List[str]] = None, continue trackers[resource_type] = GpuUsageRecorder(gpu_ids) else: - logger.warning( + raise ValueError( "Resource type {} isn't supported now. Current available types are cpu and gpu.".format(resource_type) ) diff --git a/tests/unit/cli/utils/test_experiment.py b/tests/unit/cli/utils/test_experiment.py index 7f0a695e119..e5a61a8e445 100644 --- a/tests/unit/cli/utils/test_experiment.py +++ b/tests/unit/cli/utils/test_experiment.py @@ -139,31 +139,20 @@ def test_check_resource(mocker, resource_types, tmp_path): assert Path(output_file).exists() # check a file is saved well -@pytest.mark.parametrize("resource_types", (["wrong"], None)) -@e2e_pytest_unit -def test_check_resource_wrong_resource_type(mocker, resource_types, tmp_path): +def test_check_resource_wrong_resource_type(mocker, tmp_path): # prepare + resource_types = ["wrong"] output_file = f"{tmp_path}/fake.yaml" mock_queue = MockQueue(output_file) - mock_cpu_recorder = mocker.MagicMock() - mock_cpu_recorder_cls = mocker.patch.object(target_file, "CpuUsageRecorder", return_value=mock_cpu_recorder) - mock_gpu_recorder = mocker.MagicMock() - mock_gpu_recorder_cls = mocker.patch.object(target_file, "GpuUsageRecorder", return_value=mock_gpu_recorder) - + mocker.patch.object(target_file, "CpuUsageRecorder") + mocker.patch.object(target_file, "GpuUsageRecorder") mocker.patch.object(target_file, "yaml") mocker.patch.object(target_file, "time") - # run - _check_resource(mock_queue, resource_types) - - # check the recorders aren't called - mock_cpu_recorder.record.assert_not_called() - mock_cpu_recorder_cls.assert_not_called() - mock_gpu_recorder.record.assert_not_called() - mock_gpu_recorder_cls.assert_not_called() - - assert not Path(output_file).exists() # check a file isn't saved + # check that ValueError is raised. + with pytest.raises(ValueError): + _check_resource(mock_queue, resource_types) class TestCpuUsageRecorder: