Skip to content

Commit

Permalink
Make helper method static
Browse files Browse the repository at this point in the history
  • Loading branch information
tlento committed May 17, 2024
1 parent e1dcd84 commit 909aabb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions metricflow/dataflow/dataflow_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,16 @@ def __init__(self, sink_nodes: Sequence[DataflowPlanNode], plan_id: Optional[Dag
def sink_node(self) -> DataflowPlanNode: # noqa: D102
return self._sink_nodes[0]

def __all_nodes_in_subgraph(self, node: DataflowPlanNode) -> Sequence[DataflowPlanNode]:
@staticmethod
def __all_nodes_in_subgraph(node: DataflowPlanNode) -> Sequence[DataflowPlanNode]:
"""Node accessor for retrieving a flattened sequence of all nodes in the subgraph upstream of the input node.
Useful for gathering nodes for subtype-agnostic operations, such as common property access or simple counts.
"""
flattened_parent_subgraphs = tuple(
more_itertools.collapse(self.__all_nodes_in_subgraph(parent_node) for parent_node in node.parent_nodes)
more_itertools.collapse(
DataflowPlan.__all_nodes_in_subgraph(parent_node) for parent_node in node.parent_nodes
)
)
return (node,) + flattened_parent_subgraphs

Expand All @@ -225,7 +228,7 @@ def source_semantic_models(self) -> FrozenSet[SemanticModelReference]:
return frozenset(
[
node._input_semantic_model
for node in self.__all_nodes_in_subgraph(self.sink_node)
for node in DataflowPlan.__all_nodes_in_subgraph(self.sink_node)
if node._input_semantic_model is not None
]
)

0 comments on commit 909aabb

Please sign in to comment.