Skip to content

Commit

Permalink
Add test for ctapipe-process provenance
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Nov 28, 2024
1 parent cecb79d commit 5be6b0e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/ctapipe/tools/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Test ctapipe-process on a few different use cases
"""

import json
from subprocess import CalledProcessError

import astropy.units as u
Expand Down Expand Up @@ -160,17 +161,20 @@ def test_stage1_datalevels(tmp_path):
assert isinstance(tool.event_source, DummyEventSource)


def test_stage_2_from_simtel(tmp_path):
def test_stage_2_from_simtel(tmp_path, provenance):
"""check we can go to DL2 geometry from simtel file"""
config = resource_file("stage2_config.json")
output = tmp_path / "test_stage2_from_simtel.DL2.h5"

provenance_log = tmp_path / "provenance.log"
input_path = get_dataset_path("gamma_prod5.simtel.zst")
run_tool(
ProcessorTool(),
argv=[
f"--config={config}",
"--input=dataset://gamma_prod5.simtel.zst",
f"--input={input_path}",
f"--output={output}",
f"--provenance-log={provenance_log}",
"--overwrite",
],
cwd=tmp_path,
Expand All @@ -190,6 +194,18 @@ def test_stage_2_from_simtel(tmp_path):
assert dl2["HillasReconstructor_telescopes"].dtype == np.bool_
assert dl2["HillasReconstructor_telescopes"].shape[1] == len(subarray)

activities = json.loads(provenance_log.read_text())
assert len(activities) == 1

activity = activities[0]
assert activity["status"] == "success"
assert len(activity["input"]) == 2
assert activity["input"][0]["url"] == str(config)
assert activity["input"][1]["url"] == str(input_path)

assert len(activity["output"]) == 1
assert activity["output"][0]["url"] == str(output)


def test_stage_2_from_dl1_images(tmp_path, dl1_image_file):
"""check we can go to DL2 geometry from DL1 images"""
Expand Down

0 comments on commit 5be6b0e

Please sign in to comment.