Skip to content

Commit

Permalink
Remove unused costing code
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Oct 30, 2023
1 parent ccd3711 commit 7463b96
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 264 deletions.
167 changes: 0 additions & 167 deletions metricflow/dataflow/builder/costing.py

This file was deleted.

14 changes: 5 additions & 9 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity

from metricflow.dag.id_generation import DATAFLOW_PLAN_PREFIX, IdGeneratorRegistry
from metricflow.dataflow.builder.costing import DataflowPlanNodeCostFunction, DefaultCostFunction
from metricflow.dataflow.builder.measure_additiveness import group_measure_specs_by_additiveness
from metricflow.dataflow.builder.node_data_set import DataflowPlanNodeOutputDataSetResolver
from metricflow.dataflow.builder.node_evaluator import (
Expand Down Expand Up @@ -147,14 +146,12 @@ def __init__( # noqa: D
source_nodes: Sequence[BaseOutput],
read_nodes: Sequence[ReadSqlSourceNode],
semantic_manifest_lookup: SemanticManifestLookup,
cost_function: DataflowPlanNodeCostFunction = DefaultCostFunction(),
node_output_resolver: Optional[DataflowPlanNodeOutputDataSetResolver] = None,
column_association_resolver: Optional[ColumnAssociationResolver] = None,
) -> None:
self._semantic_model_lookup = semantic_manifest_lookup.semantic_model_lookup
self._metric_lookup = semantic_manifest_lookup.metric_lookup
self._metric_time_dimension_reference = DataSet.metric_time_dimension_reference()
self._cost_function = cost_function
self._source_nodes = source_nodes
self._read_nodes = read_nodes
self._column_association_resolver = (
Expand Down Expand Up @@ -391,15 +388,14 @@ def _get_semantic_model_names_for_measures(self, measure_names: Sequence[Measure
return semantic_model_names

def _sort_by_suitability(self, nodes: Sequence[BaseOutput]) -> Sequence[BaseOutput]:
"""Sort nodes by the cost, then by the number of linkable specs.
"""Sort nodes by the number of linkable specs.
Lower cost nodes will result in faster queries, and the lower the number of linkable specs means less
aggregation required.
The lower the number of linkable specs means less aggregation required.
"""

def sort_function(node: BaseOutput) -> Tuple[int, int]:
def sort_function(node: BaseOutput) -> int:
data_set = self._node_data_set_resolver.get_output_data_set(node)
return self._cost_function.calculate_cost(node).as_int, len(data_set.instance_set.spec_set.linkable_specs)
return len(data_set.instance_set.spec_set.linkable_specs)

return sorted(nodes, key=sort_function)

Expand Down Expand Up @@ -591,7 +587,7 @@ def _find_dataflow_recipe(
logger.info(f"Found {len(node_to_evaluation)} candidate source nodes.")

if len(node_to_evaluation) > 0:
# All source nodes cost the same. Find evaluation with lowest number of joins.
# Find evaluation with lowest number of joins.
node_with_lowest_cost_plan = min(
node_to_evaluation, key=lambda node: len(node_to_evaluation[node].join_recipes)
)
Expand Down
82 changes: 0 additions & 82 deletions metricflow/test/dataflow/builder/test_costing.py

This file was deleted.

2 changes: 0 additions & 2 deletions metricflow/test/dataflow/builder/test_cyclic_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from _pytest.fixtures import FixtureRequest
from dbt_semantic_interfaces.references import EntityReference

from metricflow.dataflow.builder.costing import DefaultCostFunction
from metricflow.dataflow.builder.dataflow_plan_builder import DataflowPlanBuilder
from metricflow.dataflow.dataflow_plan_to_text import dataflow_plan_as_text
from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
Expand Down Expand Up @@ -36,7 +35,6 @@ def cyclic_join_manifest_dataflow_plan_builder( # noqa: D
source_nodes=consistent_id_object_repository.cyclic_join_source_nodes,
read_nodes=list(consistent_id_object_repository.cyclic_join_read_nodes.values()),
semantic_manifest_lookup=cyclic_join_semantic_manifest_lookup,
cost_function=DefaultCostFunction(),
)


Expand Down
4 changes: 0 additions & 4 deletions metricflow/test/fixtures/dataflow_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytest

from metricflow.dataflow.builder.costing import DefaultCostFunction
from metricflow.dataflow.builder.dataflow_plan_builder import DataflowPlanBuilder
from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow.plan_conversion.column_resolver import DunderColumnAssociationResolver
Expand Down Expand Up @@ -36,7 +35,6 @@ def dataflow_plan_builder( # noqa: D
source_nodes=consistent_id_object_repository.simple_model_source_nodes,
read_nodes=list(consistent_id_object_repository.simple_model_read_nodes.values()),
semantic_manifest_lookup=simple_semantic_manifest_lookup,
cost_function=DefaultCostFunction(),
)


Expand All @@ -50,7 +48,6 @@ def multihop_dataflow_plan_builder( # noqa: D
source_nodes=consistent_id_object_repository.multihop_model_source_nodes,
read_nodes=list(consistent_id_object_repository.multihop_model_read_nodes.values()),
semantic_manifest_lookup=multi_hop_join_semantic_manifest_lookup,
cost_function=DefaultCostFunction(),
)


Expand All @@ -72,7 +69,6 @@ def scd_dataflow_plan_builder( # noqa: D
source_nodes=consistent_id_object_repository.scd_model_source_nodes,
read_nodes=list(consistent_id_object_repository.scd_model_read_nodes.values()),
semantic_manifest_lookup=scd_semantic_manifest_lookup,
cost_function=DefaultCostFunction(),
column_association_resolver=scd_column_association_resolver,
)

Expand Down

0 comments on commit 7463b96

Please sign in to comment.