diff --git a/tests/conftest.py b/tests/conftest.py index b650a173f376307143a2c0e9ff534463398ab498..38abd0a983108402af2b2ddf1ced534a0cb79855 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -50,41 +50,6 @@ def pytest_addoption(parser): help="Skips tests marked as requiring myMDC access", ) - parser.addoption( - "--release-test", - action="store_true", - default=False, - help="Start release test for all supported calibration notebooks", - ) - detectors_choices = [] - for k in ['agipd', 'jungfrau', 'pnccd', 'epix100', 'all']: - detectors_choices += [k, k.upper()] - parser.addoption( - "--detectors", - action='append', - choices=detectors_choices, - ) - - parser.addoption( - "--calibration", - type=str, - choices=['correct', 'dark', 'all'], - default='all', - ) - - parser.addoption( - "--no-numerical-validation", - action="store_true", - default=False, - help="Skips tests for numerical validation for produced h5files.", - ) - - parser.addoption( - "--picked-test", - type=str, - default=None, - ) - def pytest_configure(config): config.addinivalue_line( @@ -102,26 +67,6 @@ def pytest_configure(config): "requires_mdc(): marks skips for tests that require calDB access", ) - config.addinivalue_line( - "markers", - "manual_run(): marks skips for tests that required to be run manually", - ) - - config.addinivalue_line( - "markers", - "manual_run(): marks skips for tests that required to be run manually", - ) - - -@pytest.fixture -def release_test_config(request): - detectors = request.config.getoption("--detectors") - calibration = request.config.getoption("--calibration") - skip_numerical_validation = request.config.getoption( - "--no-numerical-validation") - picked_test = request.config.getoption("--picked-test") - return detectors, calibration, picked_test, skip_numerical_validation - @lru_cache() def server_reachable(server: str = "max-exfl-cal002"): @@ -148,9 +93,3 @@ def pytest_runtest_setup(item): item.config.getoption("--no-mdc") ): pytest.skip("myMDC not available") - - if ( - list(item.iter_markers(name="manual_run")) and - not item.config.getoption("--release-test") - ): - pytest.skip("Test initialized manually") diff --git a/tests/test_reference_runs/__init__.py b/tests/test_reference_runs/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/test_reference_runs/callab_tests.py b/tests/test_reference_runs/callab_tests.py new file mode 100644 index 0000000000000000000000000000000000000000..5a9454acb02ca60ac53d0afadfba5409e3edcfd3 --- /dev/null +++ b/tests/test_reference_runs/callab_tests.py @@ -0,0 +1,394 @@ +automated_test_config = { + "SPB_DET_AGIPD1M-1-CORRECT-FIXED": + { + "det_type": "AGIPD", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/SPB/202131/p900215/raw", + "run": "95", + "karabo-id-control": "SPB_IRU_AGIPD1M1", + "karabo-id": "SPB_DET_AGIPD1M-1", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}" + }, + "SPB_DET_AGIPD1M-1-DARK-FIXED": + { + "det_type": "AGIPD", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/SPB/202131/p900215/raw", + "run-high": "91", + "run-med": "92", + "run-low": "93", + "karabo-id-control": "SPB_IRU_AGIPD1M1", + "karabo-id": "SPB_DET_AGIPD1M-1", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + "SPB_DET_AGIPD1M-1-CORRECT-ADAPTIVE":{ + "det_type": "AGIPD", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/SPB/202131/p900215/raw", + "run": "262", + "karabo-id-control": "SPB_IRU_AGIPD1M1", + "karabo-id": "SPB_DET_AGIPD1M-1", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + "SPB_DET_AGIPD1M-1-DARK-ADAPTIVE": + { + "det_type": "AGIPD", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/SPB/202131/p900215/raw", + "run-high": "216", + "run-med": "217", + "run-low": "218", + "karabo-id-control": "SPB_IRU_AGIPD1M1", + "karabo-id": "SPB_DET_AGIPD1M-1", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + + "MID_DET_AGIPD1M-1-CORRECT-ADAPTIVE": + { + "det_type": "AGIPD", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/MID/202121/p002929/raw", + "run": "21", + "karabo-id-control": "MID_EXP_AGIPD1M1", + "karabo-id": "MID_DET_AGIPD1M-1", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + "MID_DET_AGIPD1M-1-DARK-ADAPTIVE": + { + "det_type": "AGIPD", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/MID/202121/p002929/raw", + "run-high": "4", + "run-med": "5", + "run-low": "6", + "karabo-id-control": "MID_EXP_AGIPD1M1", + "karabo-id": "MID_DET_AGIPD1M-1", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + "HED_DET_AGIPD500K2G-CORRECT-ADAPTIVE": + { + "det_type": "AGIPD", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/HED/202131/p900228/raw", + "run": "29", + "karabo-id-control": "HED_EXP_AGIPD500K2G", + "karabo-id": "HED_DET_AGIPD500K2G", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + "HED_DET_AGIPD500K2G-DARK-ADAPTIVE":{ + "det_type": "AGIPD", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/HED/202131/p900228/raw", + "run-high": "25", + "run-med": "26", + "run-low": "27", + "karabo-id-control": "HED_EXP_AGIPD500K2G", + "karabo-id": "HED_DET_AGIPD500K2G", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + "MID_DET_AGIPD1M-1-CORRECT-SELECT_CELLS_CM": + { + "det_type": "AGIPD", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/MID/202121/p002929/raw", + "run": "21", + "max-pulses": [0, 160, 2], + "common-mode": True, + "karabo-id-control": "MID_EXP_AGIPD1M1", + "karabo-id": "MID_DET_AGIPD1M-1", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + "MID_DET_AGIPD1M-1-CORRECT-SELECT_CELLS_NOCM": + { + "det_type": "AGIPD", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/MID/202121/p002929/raw", + "run": "21", + "max-pulses": [0, 160, 2], + + "no-common-mode": True, + "karabo-id-control": "MID_EXP_AGIPD1M1", + "karabo-id": "MID_DET_AGIPD1M-1", + "slurm-mem": "750", + "ctrl-source-template": "{}/MDL/FPGA_COMP", + }, + "reference-folder": "{}/{}/{}", + }, + "FXE_XAD_JF500K-DARK-SINGLE": + { + "det_type": "JUNGFRAU", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/FXE/202101/p002478/raw/", + "run-high": "47", + "run-med": "48", + "run-low": "49", + "karabo-id-control": "", + "karabo-id": "FXE_XAD_JF500K", + "karabo-da": "JNGFR03", + }, + "reference-folder": "{}/{}/{}", + }, + "FXE_XAD_JF500K-CORRECT-SINGLE": + { + "det_type": "JUNGFRAU", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/FXE/202101/p002478/raw/", + "run": "52", + "karabo-id-control": "", + "karabo-id": "FXE_XAD_JF500K", + "karabo-da": "JNGFR03", + }, + "reference-folder": "{}/{}/{}", + }, + "FXE_XAD_JF1M-DARK-BURST": + { + "det_type": "JUNGFRAU", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/FXE/202131/p900226/raw/", + "run-high": "108", + "run-med": "109", + "run-low": "110", + "karabo-id-control": "", + "karabo-id": "FXE_XAD_JF1M", + "karabo-da": ["JNGFR01", "JNGFR02"], + }, + "reference-folder": "{}/{}/{}", + }, + "FXE_XAD_JF1M-CORRECT-BURST": + { + "det_type": "JUNGFRAU", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/FXE/202131/p900226/raw", + "run": "106", + "karabo-id-control": "", + "karabo-id": "FXE_XAD_JF1M", + "karabo-da": ["JNGFR01", "JNGFR02"], + }, + "reference-folder": "{}/{}/{}", + }, + "FXE_XAD_JF1M-DARK-SINGLE": + { + "det_type": "JUNGFRAU", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/FXE/202101/p002478/raw/", + "run-high": "47", + "run-med": "48", + "run-low": "49", + "karabo-id-control": "", + "karabo-id": "FXE_XAD_JF1M", + "karabo-da": ["JNGFR01", "JNGFR02"], + }, + "reference-folder": "{}/{}/{}", + }, + "FXE_XAD_JF1M-CORRECT-SINGLE": + { + "det_type": "JUNGFRAU", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/FXE/202101/p002478/raw/", + "run": "52", + "karabo-id-control": "", + "karabo-id": "FXE_XAD_JF1M", + "karabo-da": ["JNGFR01", "JNGFR02"], + }, + "reference-folder": "{}/{}/{}", + }, + "SPB_IRDA_JF4M-CORRECT-SINGLE": + { + "det_type": "JUNGFRAU", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/SPB/202130/p900204/raw", + "run": "91", + "karabo-id-control": "", + "karabo-id": "SPB_IRDA_JF4M", + "karabo-da": [ + "JNGFR01", "JNGFR02", "JNGFR03", "JNGFR04", + "JNGFR05", "JNGFR06", "JNGFR07", "JNGFR08" + ], + }, + "reference-folder": "{}/{}/{}", + }, + "SPB_IRDA_JF4M-DARK-ADAPTIVE": + { + "det_type": "JUNGFRAU", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/SPB/202130/p900204/raw", + "run-high": "88", + "run-med": "89", + "run-low": "90", + "karabo-id-control": "", + "karabo-id": "SPB_IRDA_JF4M", + "karabo-da": [ + "JNGFR01", "JNGFR02", "JNGFR03", "JNGFR04", + "JNGFR05", "JNGFR06", "JNGFR07", "JNGFR08" + ], + }, + "reference-folder": "{}/{}/{}", + }, + "HED_IA1_JF500K1-CORRECT-ADAPTIVE": + { + "det_type": "JUNGFRAU", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/HED/202102/p002656/raw", + "run": "230", + "karabo-id": "HED_IA1_JF500K1", + "karabo-da": "JNGFR01", + }, + "reference-folder": "{}/{}/{}", + }, + "HED_IA1_JF500K1-DARK-ADAPTIVE": + { + "det_type": "JUNGFRAU", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/HED/202102/p002656/raw", + "run-high": "219", + "run-med": "220", + "run-low": "221", + "karabo-id": "HED_IA1_JF500K1", + "karabo-da": "JNGFR01", + }, + "reference-folder": "{}/{}/{}", + }, + "HED_IA1_EPX100-1-CORRECT": + { + "det_type": "EPIX100", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/HED/202102/p002656/raw", + "run": "230", + "karabo-id": "HED_IA1_EPX100-1", + "karabo-da": "EPIX01", + }, + "reference-folder": "{}/{}/{}", + }, + "HED_IA1_EPX100-1-DARK": + { + "det_type": "EPIX100", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/HED/202102/p002656/raw", + "run": "219", + "karabo-id": "HED_IA1_EPX100-1", + "karabo-da": "EPIX01", + }, + "reference-folder": "{}/{}/{}", + }, + "SQS_NQS_PNCCD1MP-CORRECT": + { + "det_type": "PNCCD", + "cal_type": "CORRECT", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/SQS/202031/p900166/raw", + "run": "347", + "karabo-id": "SQS_NQS_PNCCD1MP", + "karabo-da": "PNCCD01", + }, + "reference-folder": "{}/{}/{}" + }, + "SQS_NQS_PNCCD1MP-DARK": + { + "det_type": "PNCCD", + "cal_type": "DARK", + "config": + { + "out-folder": "{}/{}/{}", + "in-folder": "/gpfs/exfel/exp/SQS/202031/p900166/raw", + "run": "345", + "karabo-id": "SQS_NQS_PNCCD1MP", + "karabo-da": "PNCCD01", + }, + "reference-folder": "{}/{}/{}", + }, +} \ No newline at end of file diff --git a/tests/callab_tests.yaml b/tests/test_reference_runs/callab_tests.yaml similarity index 100% rename from tests/callab_tests.yaml rename to tests/test_reference_runs/callab_tests.yaml diff --git a/tests/test_reference_runs/conftest.py b/tests/test_reference_runs/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..21d55eabc8868642d85a63d7129ef4bf73afbeef --- /dev/null +++ b/tests/test_reference_runs/conftest.py @@ -0,0 +1,74 @@ +import pytest + + +def pytest_addoption(parser): + + parser.addoption( + "--release-test", + action="store_true", + default=False, + help="Start release test for all supported calibration notebooks", + ) + detectors_choices = [] + for k in ['agipd', 'jungfrau', 'pnccd', 'epix100', 'all']: + detectors_choices += [k, k.upper()] + parser.addoption( + "--detectors", + action='append', + choices=detectors_choices, + default=['all'], + ) + + parser.addoption( + "--calibration", + type=str, + choices=['correct', 'dark', 'all'], + default='all', + ) + + parser.addoption( + "--no-numerical-validation", + action="store_true", + default=False, + help="Skips tests for numerical validation for produced h5files.", + ) + + parser.addoption( + "--picked-test", + type=str, + default=None, + ) + + parser.addoption( + "--out-folder", + type=str, + ) + + parser.addoption( + "--reference-folder", + type=str, + ) + +@pytest.fixture +def release_test_config(request): + detectors = request.config.getoption("--detectors") + calibration = request.config.getoption("--calibration") + skip_numerical_validation = request.config.getoption( + "--no-numerical-validation") + picked_test = request.config.getoption("--picked-test") + return detectors, calibration, picked_test, skip_numerical_validation + + +def pytest_configure(config): + config.addinivalue_line( + "markers", + "manual_run(): marks skips for tests that required to be run manually", + ) + + +def pytest_runtest_setup(item): + if ( + list(item.iter_markers(name="manual_run")) and + not item.config.getoption("--release-test") + ): + pytest.skip("Test initialized manually") \ No newline at end of file diff --git a/tests/test_pre_deployment.py b/tests/test_reference_runs/test_pre_deployment.py similarity index 94% rename from tests/test_pre_deployment.py rename to tests/test_reference_runs/test_pre_deployment.py index 99465fae7aa42d1be978cd77772da3796e1a3745..5258ee46d8e16f1d14ea617a9c01daad7abb5955 100644 --- a/tests/test_pre_deployment.py +++ b/tests/test_reference_runs/test_pre_deployment.py @@ -17,11 +17,7 @@ import yaml import xfel_calibrate.calibrate as calibrate from cal_tools import h5_copy_except -REFERENCE_FOLDER = "/gpfs/exfel/data/scratch/ahmedk/test/release_test_3.5.0b3/" -OUT_FOLDER = "/gpfs/exfel/data/scratch/ahmedk/test/3.5.1test1/" - -with open("./tests/callab_tests.yaml", "r") as f: - callab_test_dict = yaml.load(f) +from .callab_tests import automated_test_config def file_md5( @@ -151,8 +147,8 @@ def parse_config( @pytest.mark.manual_run @pytest.mark.parametrize( "test_key, val_dict", - list(callab_test_dict.items()), - ids=list(callab_test_dict.keys()), + list(automated_test_config.items()), + ids=list(automated_test_config.keys()), ) def test_xfel_calibrate( test_key: str, val_dict: dict, @@ -168,8 +164,8 @@ def test_xfel_calibrate( """ ( - detectors, calibration, - picked_test, skip_numerical_validation + detectors, calibration, picked_test, + skip_numerical_validation, reference_dir_base, out_dir_base, ) = release_test_config cal_type = val_dict["cal_type"] @@ -196,11 +192,11 @@ def test_xfel_calibrate( cal_conf["report-to"] = report_name out_folder = pathlib.Path(cal_conf["out-folder"].format( - OUT_FOLDER, cal_conf["karabo-id"], test_key)) + out_dir_base, cal_conf["karabo-id"], test_key)) cmd = parse_config(cmd, cal_conf, out_folder) reference_folder = pathlib.Path(val_dict["reference-folder"].format( - REFERENCE_FOLDER, cal_conf["karabo-id"], test_key)) + reference_dir_base, cal_conf["karabo-id"], test_key)) cmd += ["--slurm-name", test_key] f = io.StringIO()