diff --git a/apps/step_update/cli.py b/apps/step_update/cli.py index 2a55a8a2833..d6818598c7a 100644 --- a/apps/step_update/cli.py +++ b/apps/step_update/cli.py @@ -342,6 +342,7 @@ def update_steps( excludes=[], downstream=False, only=True, + exact_match=True, ) message = "The following steps will be updated:" diff --git a/etl/steps/__init__.py b/etl/steps/__init__.py index f826ed4bbaa..d19a1eb7369 100644 --- a/etl/steps/__init__.py +++ b/etl/steps/__init__.py @@ -76,13 +76,18 @@ def to_dependency_order( excludes: List[str], downstream: bool = False, only: bool = False, + exact_match: bool = False, ) -> List[str]: """ Organize the steps in dependency order with a topological sort. In other words, the resulting list of steps is a valid ordering of steps such that no step is run before the steps it depends on. Note: this ordering is not necessarily unique. """ - subgraph = filter_to_subgraph(dag, includes, downstream=downstream, only=only) if includes else dag + subgraph = ( + filter_to_subgraph(dag, includes, downstream=downstream, only=only, exact_match=exact_match) + if includes + else dag + ) in_order = list(graphlib.TopologicalSorter(subgraph).static_order()) # filter out explicit excludes @@ -91,7 +96,9 @@ def to_dependency_order( return filtered -def filter_to_subgraph(graph: Graph, includes: Iterable[str], downstream: bool = False, only: bool = False) -> Graph: +def filter_to_subgraph( + graph: Graph, includes: Iterable[str], downstream: bool = False, only: bool = False, exact_match: bool = False +) -> Graph: """ Filter the full graph to only the included nodes, and all their dependencies. @@ -102,7 +109,10 @@ def filter_to_subgraph(graph: Graph, includes: Iterable[str], downstream: bool = dependent on B). """ all_steps = graph_nodes(graph) - included = {s for s in all_steps if any(re.findall(pattern, s) for pattern in includes)} + if exact_match: + included = set(includes) & all_steps + else: + included = {s for s in all_steps if any(re.findall(pattern, s) for pattern in includes)} if only: # Only include explicitly selected nodes