From 72fe5580032ef42012ee2bd38351a7cafa2ef34b Mon Sep 17 00:00:00 2001 From: thibaultdvx <154365476+thibaultdvx@users.noreply.github.com> Date: Wed, 29 May 2024 18:46:02 +0200 Subject: [PATCH] modify ref instead of output --- tests/conftest.py | 19 ++++++++++--------- tests/test_train_ae.py | 16 ++++++++-------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index ed7990a31..e5a4a7302 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,20 +15,21 @@ def pytest_addoption(parser): help="Directory for (only-read) inputs for tests", ) parser.addoption( - "--simulate-gpu", + "--no-gpu", action="store_true", - help="""To simulate the presence of a gpu on a cpu-only device. Default is False. + help="""To run tests on cpu. Default is False. To use carefully, only to run tests locally. Should not be used in final CI tests. - Concretely, the tests won't fail if gpu option if false in the output MAPS whereas - it should be true.""", + Concretely, the tests won't fail if gpu option is false in the output MAPS whereas + it is true in the reference MAPS.""", ) parser.addoption( "--adapt-base-dir", action="store_true", - help="""To virtually change the base directory in the paths stored in MAPS. Default is False. + help="""To virtually change the base directory in the paths stored in the MAPS of the CI data. + Default is False. To use carefully, only to run tests locally. Should not be used in final CI tests. - Concretely, the tests won't fail if only the base directory differs in the paths stored - in the MAPS.""", + Concretely, the tests won't fail if only the base directories differ in the paths stored + in the output and reference MAPS.""", ) @@ -36,6 +37,6 @@ def pytest_addoption(parser): def cmdopt(request): config_param = {} config_param["input"] = request.config.getoption("--input_data_directory") - config_param["simulate gpu"] = request.config.getoption("--simulate-gpu") - config_param["adapt base dir"] = request.config.getoption("--adapt-base-dir") + config_param["no-gpu"] = request.config.getoption("--no-gpu") + config_param["adapt-base-dir"] = request.config.getoption("--adapt-base-dir") return config_param diff --git a/tests/test_train_ae.py b/tests/test_train_ae.py index ed727610b..311e145d0 100644 --- a/tests/test_train_ae.py +++ b/tests/test_train_ae.py @@ -88,7 +88,7 @@ def test_train_ae(cmdopt, tmp_path, test_name): else: raise NotImplementedError(f"Test {test_name} is not implemented.") - if cmdopt["simulate gpu"]: + if cmdopt["no-gpu"]: test_input.append("--no-gpu") if tmp_out_dir.is_dir(): @@ -104,16 +104,16 @@ def test_train_ae(cmdopt, tmp_path, test_name): if test_name == "patch_multi_ae": json_data_out["multi_network"] = True - if cmdopt["simulate gpu"]: - json_data_out["gpu"] = True - if cmdopt["adapt base dir"]: + if cmdopt["no-gpu"]: + json_data_ref["gpu"] = False + if cmdopt["adapt-base-dir"]: base_dir = base_dir.resolve() ref_base_dir = Path(json_data_ref["caps_directory"]).parents[2] - json_data_out["caps_directory"] = str( - ref_base_dir / Path(json_data_out["caps_directory"]).relative_to(base_dir) + json_data_ref["caps_directory"] = str( + base_dir / Path(json_data_ref["caps_directory"]).relative_to(ref_base_dir) ) - json_data_out["tsv_path"] = str( - ref_base_dir / Path(json_data_out["tsv_path"]).relative_to(base_dir) + json_data_ref["tsv_path"] = str( + base_dir / Path(json_data_ref["tsv_path"]).relative_to(ref_base_dir) ) assert json_data_out == json_data_ref # ["mode"] == mode