Skip to content

Commit

Permalink
Merge pull request #118 from HealthyPear/fix-integration-tests
Browse files Browse the repository at this point in the history
Fix pipeline integration test workflow
  • Loading branch information
HealthyPear authored Mar 29, 2021
2 parents 21b483c + 01b3aa2 commit 6d7a41f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion protopipe/scripts/tests/test_config_analysis_north.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# General informations
# NOTE: only Prod3b simulations are currently supported.
General:
config_name: 'v0.4.0_dev1'
config_name: 'test_CTA_North'
site: 'north' # 'north' or 'south'
# array can be either
# - 'subarray_LSTs', 'subarray_MSTs', 'subarray_SSTs' or 'full_array'
Expand Down
2 changes: 1 addition & 1 deletion protopipe/scripts/tests/test_config_analysis_south.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# General informations
# NOTE: only Prod3b simulations are currently supported.
General:
config_name: 'v0.4.0_dev1'
config_name: 'test_CTA_South'
site: 'south' # 'north' or 'south'
# array can be either
# - 'subarray_LSTs', 'subarray_MSTs', 'subarray_SSTs' or 'full_array'
Expand Down
70 changes: 40 additions & 30 deletions protopipe/scripts/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,48 @@ def test_GET_GAMMAS_FOR_ENERGY_MODEL(test_case, pipeline_testdir):


@pytest.mark.parametrize("test_case", [
pytest.param("PROD3B_CTA_NORTH", marks=pytest.mark.dependency(name="g2N")),
pytest.param("PROD3B_CTA_SOUTH", marks=pytest.mark.dependency(name="g2S")),
pytest.param("PROD3B_CTA_NORTH", marks=pytest.mark.dependency(name="EN",
depends=["g1N"])),
pytest.param("PROD3B_CTA_SOUTH", marks=pytest.mark.dependency(name="ES",
depends=["g1S"])),
])
def test_BUILD_ENERGY_MODEL_AdaBoost_DecisionTreeRegressor(test_case, pipeline_testdir):
"""Launch protopipe.scripts.build_model for a AdaBoost DecisionTreeRegressor."""

infile = pipeline_testdir / f"test_gamma1_noImages_{test_case}.h5"
outdir = pipeline_testdir / f"energy_model_{test_case}"

config = resource_filename("protopipe", "scripts/tests/test_regressor.yaml")

exit_status = system(
f"python {build_model.__file__}\
--config_file {config}\
--infile_signal {infile}\
--outdir {outdir}\
--cameras_from_file"
)
assert exit_status == 0


@pytest.mark.parametrize("test_case", [
pytest.param("PROD3B_CTA_NORTH", marks=pytest.mark.dependency(name="g2N",
depends=["EN"])),
pytest.param("PROD3B_CTA_SOUTH", marks=pytest.mark.dependency(name="g2S",
depends=["ES"])),
])
def test_GET_GAMMAS_FOR_CLASSIFICATION_MODEL(test_case, pipeline_testdir):

modelpath = pipeline_testdir / f"energy_model_{test_case}"
outpath = pipeline_testdir / f"test_gamma2_noImages_{test_case}.h5"

exit_status = system(
f"python {data_training.__file__}\
--config_file {input_data[test_case]['config']}\
-o {outpath}\
-i {input_data[test_case]['gamma2'].parent}\
-f {input_data[test_case]['gamma2'].name}"
-f {input_data[test_case]['gamma2'].name}\
--estimate_energy True\
--regressor_dir {modelpath}"
)

# check that the script ends without crashing
Expand All @@ -114,11 +143,14 @@ def test_GET_GAMMAS_FOR_CLASSIFICATION_MODEL(test_case, pipeline_testdir):


@pytest.mark.parametrize("test_case", [
pytest.param("PROD3B_CTA_NORTH", marks=pytest.mark.dependency(name="p1N")),
pytest.param("PROD3B_CTA_SOUTH", marks=pytest.mark.dependency(name="p1S")),
pytest.param("PROD3B_CTA_NORTH", marks=pytest.mark.dependency(name="p1N",
depends=["EN"])),
pytest.param("PROD3B_CTA_SOUTH", marks=pytest.mark.dependency(name="p1S",
depends=["ES"])),
])
def test_GET_PROTONS_FOR_CLASSIFICATION_MODEL(test_case, pipeline_testdir):

modelpath = pipeline_testdir / f"energy_model_{test_case}"
outpath = pipeline_testdir / f"test_proton1_noImages_{test_case}.h5"

exit_status = system(
Expand All @@ -127,7 +159,9 @@ def test_GET_PROTONS_FOR_CLASSIFICATION_MODEL(test_case, pipeline_testdir):
-o {outpath}\
-m 10\
-i {input_data[test_case]['proton1'].parent}\
-f {input_data[test_case]['proton1'].name}"
-f {input_data[test_case]['proton1'].name}\
--estimate_energy True\
--regressor_dir {modelpath}"
)

# check that the script ends without crashing
Expand All @@ -138,30 +172,6 @@ def test_GET_PROTONS_FOR_CLASSIFICATION_MODEL(test_case, pipeline_testdir):
assert file.get_filesize() > 0


@pytest.mark.parametrize("test_case", [
pytest.param("PROD3B_CTA_NORTH", marks=pytest.mark.dependency(name="EN",
depends=["g1N"])),
pytest.param("PROD3B_CTA_SOUTH", marks=pytest.mark.dependency(name="ES",
depends=["g1S"])),
])
def test_BUILD_ENERGY_MODEL_AdaBoost_DecisionTreeRegressor(test_case, pipeline_testdir):
"""Launch protopipe.scripts.build_model for a AdaBoost DecisionTreeRegressor."""

infile = pipeline_testdir / f"test_gamma1_noImages_{test_case}.h5"
outdir = pipeline_testdir / f"energy_model_{test_case}"

config = resource_filename("protopipe", "scripts/tests/test_regressor.yaml")

exit_status = system(
f"python {build_model.__file__}\
--config_file {config}\
--infile_signal {infile}\
--outdir {outdir}\
--cameras_from_file"
)
assert exit_status == 0


@pytest.mark.parametrize("test_case", [
pytest.param("PROD3B_CTA_NORTH", marks=pytest.mark.dependency(name="C1",
depends=["g2N", "p1N"])),
Expand Down

0 comments on commit 6d7a41f

Please sign in to comment.