Skip to content

Commit

Permalink
Fix broken non-metadata input checks in gatherResourceUsage.
Browse files Browse the repository at this point in the history
This is another reminder that MyPy isn't actually being run in this
package despite all of the type annotations (DM-40716), and I suspect
it was never seen at runtime because the CLI automatically avoids these
cases.  But that's no reason to leave it broken at a lower level.
  • Loading branch information
TallJimbo committed Feb 5, 2025
1 parent 69c09e7 commit a41db74
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions python/lsst/analysis/tools/tasks/gatherResourceUsage.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ def __init__(
gather_task_label, gather_dataset_type_name = self._add_gather_task(
pipeline_graph, input_metadata_dataset_type
)
if gather_task_label is None or gather_dataset_type_name is None:
continue
metadata_refs[gather_task_label] = refs_for_type
consolidate_config.input_names.append(gather_dataset_type_name)
pipeline_graph.add_task(
Expand Down Expand Up @@ -649,7 +651,7 @@ def __init__(
@classmethod
def _add_gather_task(
cls, pipeline_graph: PipelineGraph, input_metadata_dataset_type: DatasetType
) -> tuple[str, str]:
) -> tuple[str | None, str | None]:
"""Add a single configuration of `GatherResourceUsageTask` to a
pipeline graph.
Expand All @@ -664,15 +666,19 @@ def _add_gather_task(
Returns
-------
gather_task_label : `str`
Label of the new task in the pipeline.
gather_dataset_type_name : `str
Name of the task's output table dataset type.
gather_task_label : `str` or `None`
Label of the new task in the pipeline, or `None` if the given
dataset type is not a metadata dataset type or is itself a
gatherResourceUsage metadata dataset type.
gather_dataset_type_name : `str or `None`
Name of the task's output table dataset type, or `None` if the
given dataset type is not a metadata dataset type or is itself a
gatherResourceUsage metadata dataset type.
"""
if (m := re.fullmatch(r"^(\w+)_metadata$", input_metadata_dataset_type.name)) is None:
return
return None, None
elif "gatherResourceUsage" in input_metadata_dataset_type.name:
return
return None, None
else:
input_task_label = m.group(1)
gather_task_label = f"{input_task_label}_gatherResourceUsage"
Expand Down

0 comments on commit a41db74

Please sign in to comment.