Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pipeline integration test workflow #118

Merged
merged 2 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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