Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ID Consistency in Fixtures / Snapshots. #1025

Merged
merged 13 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion metricflow/model/semantics/semantic_model_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__( # noqa: D
] = {}

self._semantic_model_reference_to_semantic_model: Dict[SemanticModelReference, SemanticModel] = {}
for semantic_model in self._model.semantic_models:
for semantic_model in sorted(self._model.semantic_models, key=lambda semantic_model: semantic_model.name):
self._add_semantic_model(semantic_model)

def get_dimension_references(self) -> Sequence[DimensionReference]: # noqa: D
Expand Down
2 changes: 1 addition & 1 deletion metricflow/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from metricflow.test.fixtures.cli_fixtures import * # noqa: F401, F403
from metricflow.test.fixtures.dataflow_fixtures import * # noqa: F401, F403
from metricflow.test.fixtures.id_fixtures import * # noqa: F401, F403
from metricflow.test.fixtures.model_fixtures import * # noqa: F401, F403
from metricflow.test.fixtures.manifest_fixtures import * # noqa: F401, F403
from metricflow.test.fixtures.setup_fixtures import * # noqa: F401, F403
from metricflow.test.fixtures.sql_client_fixtures import * # noqa: F401, F403
from metricflow.test.fixtures.sql_fixtures import * # noqa: F401, F403
Expand Down
17 changes: 4 additions & 13 deletions metricflow/test/dataflow/builder/test_cyclic_join.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from __future__ import annotations

import logging
from typing import Mapping

import pytest
from _pytest.fixtures import FixtureRequest
from dbt_semantic_interfaces.references import EntityReference

from metricflow.dataflow.builder.dataflow_plan_builder import DataflowPlanBuilder
from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow.specs.specs import (
DimensionSpec,
MetricFlowQuerySpec,
MetricSpec,
)
from metricflow.test.dataflow_plan_to_svg import display_graph_if_requested
from metricflow.test.fixtures.model_fixtures import ConsistentIdObjectRepository
from metricflow.test.fixtures.manifest_fixtures import MetricFlowEngineTestFixture, SemanticManifestSetup
from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState
from metricflow.test.fixtures.sql_client_fixtures import sql_client # noqa: F401, F403
from metricflow.test.snapshot_utils import assert_plan_snapshot_text_equal
Expand All @@ -24,18 +24,9 @@

@pytest.fixture
def cyclic_join_manifest_dataflow_plan_builder( # noqa: D
cyclic_join_semantic_manifest_lookup: SemanticManifestLookup,
consistent_id_object_repository: ConsistentIdObjectRepository,
mf_engine_test_fixture_mapping: Mapping[SemanticManifestSetup, MetricFlowEngineTestFixture]
) -> DataflowPlanBuilder:
for source_node in consistent_id_object_repository.cyclic_join_source_nodes:
logger.error(f"Source node is: {source_node}")

return DataflowPlanBuilder(
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,
time_spine_source_node=consistent_id_object_repository.cyclic_join_time_spine_source_node,
)
return mf_engine_test_fixture_mapping[SemanticManifestSetup.CYCLIC_JOIN_MANIFEST].dataflow_plan_builder


def test_cyclic_join( # noqa: D
Expand Down
9 changes: 5 additions & 4 deletions metricflow/test/dataflow/builder/test_node_data_set.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
from typing import Mapping

from _pytest.fixtures import FixtureRequest
from dbt_semantic_interfaces.references import SemanticModelElementReference
Expand All @@ -24,7 +25,7 @@
)
from metricflow.sql.sql_exprs import SqlColumnReference, SqlColumnReferenceExpression
from metricflow.sql.sql_plan import SqlJoinType, SqlSelectColumn, SqlSelectStatementNode, SqlTableFromClauseNode
from metricflow.test.fixtures.model_fixtures import ConsistentIdObjectRepository
from metricflow.test.fixtures.manifest_fixtures import MetricFlowEngineTestFixture, SemanticManifestSetup
from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState
from metricflow.test.snapshot_utils import assert_spec_set_snapshot_equal

Expand Down Expand Up @@ -90,7 +91,7 @@ def test_no_parent_node_data_set(
def test_joined_node_data_set( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
consistent_id_object_repository: ConsistentIdObjectRepository,
mf_engine_test_fixture_mapping: Mapping[SemanticManifestSetup, MetricFlowEngineTestFixture],
simple_semantic_manifest_lookup: SemanticManifestLookup,
time_spine_source: TimeSpineSource,
) -> None:
Expand All @@ -101,8 +102,8 @@ def test_joined_node_data_set( # noqa: D
)

# Join "revenue" with "users_latest" to get "user__home_state_latest"
revenue_node = consistent_id_object_repository.simple_model_read_nodes["revenue"]
users_node = consistent_id_object_repository.simple_model_read_nodes["users_latest"]
revenue_node = mf_engine_test_fixture_mapping[SemanticManifestSetup.SIMPLE_MANIFEST].read_node_mapping["revenue"]
users_node = mf_engine_test_fixture_mapping[SemanticManifestSetup.SIMPLE_MANIFEST].read_node_mapping["users_latest"]
join_node = JoinToBaseOutputNode(
left_node=revenue_node,
join_targets=[
Expand Down
Loading
Loading