Skip to content

Commit 6f9868b

Browse files
committed
Allow PipelineStepTester to accept a URI
1 parent f568e4e commit 6f9868b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

python/lsst/pipe/base/tests/pipelineStepTester.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
from lsst.daf.butler import Butler, DatasetType
3737
from lsst.pipe.base import Pipeline, PipelineGraph
38+
from lsst.resources import ResourcePath, ResourcePathExpression
3839

3940

4041
@dataclasses.dataclass
@@ -57,8 +58,8 @@ class PipelineStepTester:
5758
5859
Attributes
5960
----------
60-
filename : `str`
61-
The full path to the pipeline YAML.
61+
filename : `lsst.resources.ResourcePathExpression`
62+
The full path or UI to the pipeline YAML.
6263
step_suffixes : `list` [`str`]
6364
A list, in the order of data reduction, of the step subsets to check.
6465
Must include any initial "#".
@@ -78,7 +79,7 @@ class PipelineStepTester:
7879
"task:subtask.field".
7980
"""
8081

81-
filename: str
82+
filename: ResourcePathExpression
8283
step_suffixes: list[str]
8384
initial_dataset_types: list[tuple[str, set[str], str, bool]]
8485
expected_inputs: set[str]
@@ -130,8 +131,10 @@ def run(self, butler: Butler, test_case: unittest.TestCase) -> None:
130131
all_outputs: dict[str, DatasetType] = dict()
131132
pure_inputs: dict[str, str] = dict()
132133

134+
file_uri = ResourcePath(self.filename, forceDirectory=False)
133135
for suffix in self.step_suffixes:
134-
step_graph = self.load_pipeline_graph(self.filename + suffix)
136+
step_uri = file_uri.replace(fragment=suffix.removeprefix("#"))
137+
step_graph = self.load_pipeline_graph(step_uri)
135138
step_graph.resolve(butler.registry)
136139

137140
for name, _ in step_graph.iter_overall_inputs():
@@ -160,7 +163,7 @@ def run(self, butler: Butler, test_case: unittest.TestCase) -> None:
160163
missing = list(self.expected_outputs - all_outputs.keys())
161164
raise AssertionError(f"Missing expected_outputs: {missing}")
162165

163-
def load_pipeline_graph(self, uri: str) -> PipelineGraph:
166+
def load_pipeline_graph(self, uri: ResourcePathExpression) -> PipelineGraph:
164167
pipeline = Pipeline.from_uri(uri)
165168
for fullkey, value in self.pipeline_patches.items():
166169
label, key = fullkey.split(":", maxsplit=1)

0 commit comments

Comments
 (0)