Skip to content

Commit

Permalink
fix pipeline_type for pipestat usage with consolidated pipelines, fix…
Browse files Browse the repository at this point in the history
… remaning tests
  • Loading branch information
donaldcampbelljr committed Jun 27, 2024
1 parent 168f012 commit 2d2475b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion looper/cli_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def run_looper(args: TopLevelParser, parser: ArgumentParser, test_args=None):
# Check at the beginning if user wants to use pipestat and pipestat is configurable
is_pipestat_configured = (
prj._check_if_pipestat_configured(pipeline_type=PipelineLevel.PROJECT.value)
if getattr(subcommand_args, "project", None)
if getattr(subcommand_args, "project", None) or subcommand_name == "runp"
else prj._check_if_pipestat_configured()
)

Expand Down
17 changes: 10 additions & 7 deletions looper/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,12 @@ def _get_pipestat_configuration(self, pipeline_type=PipelineLevel.SAMPLE.value):
pipestat_config_path = self._check_for_existing_pipestat_config(piface)

if not pipestat_config_path:
self._create_pipestat_config(piface)
self._create_pipestat_config(piface, pipeline_type)
else:
piface.psm = PipestatManager(
config_file=pipestat_config_path, multi_pipelines=True
config_file=pipestat_config_path,
multi_pipelines=True,
pipeline_type="sample",
)

elif pipeline_type == PipelineLevel.PROJECT.value:
Expand All @@ -426,10 +428,12 @@ def _get_pipestat_configuration(self, pipeline_type=PipelineLevel.SAMPLE.value):
)

if not pipestat_config_path:
self._create_pipestat_config(prj_piface)
self._create_pipestat_config(prj_piface, pipeline_type)
else:
prj_piface.psm = PipestatManager(
config_file=pipestat_config_path, multi_pipelines=True
config_file=pipestat_config_path,
multi_pipelines=True,
pipeline_type="project",
)
else:
_LOGGER.error(
Expand Down Expand Up @@ -469,7 +473,7 @@ def _check_for_existing_pipestat_config(self, piface):
else:
return None

def _create_pipestat_config(self, piface):
def _create_pipestat_config(self, piface, pipeline_type):
"""
Each piface needs its own config file and associated psm
"""
Expand Down Expand Up @@ -512,11 +516,10 @@ def _create_pipestat_config(self, piface):
pipestat_config_dict.update({"pipeline_name": piface.data["pipeline_name"]})
else:
pipeline_name = None
if "pipeline_type" in piface.data:
pipestat_config_dict.update({"pipeline_type": piface.data["pipeline_type"]})

# Warn user if there is a mismatch in pipeline_names from sources!!!
if pipeline_name != output_schema_pipeline_name:
# TODO Raise exception here.
_LOGGER.warning(
msg=f"Pipeline name mismatch detected. Pipeline interface: {pipeline_name} Output schema: {output_schema_pipeline_name} Defaulting to pipeline_interface value."
)
Expand Down
10 changes: 4 additions & 6 deletions tests/smoketests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ def test_looper_single_pipeline(self, prep_temp_pep):
with mod_yaml_data(tp) as config_data:

pifaces = config_data[PIPELINE_INTERFACES_KEY]
config_data[PIPELINE_INTERFACES_KEY]["sample"] = pifaces["sample"][1]
del config_data[PIPELINE_INTERFACES_KEY]["project"]
config_data[PIPELINE_INTERFACES_KEY] = pifaces[0]

x = test_args_expansion(tp, "run")
try:
Expand Down Expand Up @@ -193,7 +192,7 @@ def test_looper_cli_pipeline(self, prep_temp_pep):
tp = prep_temp_pep
with mod_yaml_data(tp) as config_data:
pifaces = config_data[PIPELINE_INTERFACES_KEY]
pi_pth = pifaces["sample"][1]
pi_pth = pifaces[1]
x = test_args_expansion(tp, "run", ["--sample-pipeline-interfaces", pi_pth])
try:
result = main(test_args=x)
Expand Down Expand Up @@ -224,7 +223,7 @@ def test_looper_pipeline_not_found(self, prep_temp_pep):
"""
tp = prep_temp_pep
with mod_yaml_data(tp) as config_data:
config_data[PIPELINE_INTERFACES_KEY]["sample"] = ["bogus"]
config_data[PIPELINE_INTERFACES_KEY] = ["bogus"]
x = test_args_expansion(tp, "run")
try:
result = main(test_args=x)
Expand Down Expand Up @@ -344,10 +343,9 @@ def test_looper_single_pipeline(self, prep_temp_pep):

with mod_yaml_data(tp) as config_data:
# Modifying in this way due to https://github.com/pepkit/looper/issues/474
config_data[PIPELINE_INTERFACES_KEY]["project"] = os.path.join(
config_data[PIPELINE_INTERFACES_KEY] = os.path.join(
os.path.dirname(tp), "pipeline/pipeline_interface1_project.yaml"
)
del config_data[PIPELINE_INTERFACES_KEY]["sample"]

print(tp)
x = test_args_expansion(tp, "runp")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_comprehensive.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_comprehensive_looper_pipestat(prep_temp_pep_pipestat):

try:
result = main(test_args=x)
assert result == {"example_pipestat_project_pipeline": {"project": "unknown"}}
assert result == {"example_pipestat_pipeline": {"project": "unknown"}}

except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))
Expand Down

0 comments on commit 2d2475b

Please sign in to comment.