From 0ea3d94c8caa8b88afb517e6f0d93f79032c2e43 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 10 Dec 2024 18:00:11 -0800 Subject: [PATCH 1/2] /* PR_START p--misc 03 */ Rename `MetricFlowTestConfiguration` in snapshot-generation script. --- tests_metricflow/generate_snapshots.py | 22 +++++++++---------- .../populate_persistent_source_schemas.py | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests_metricflow/generate_snapshots.py b/tests_metricflow/generate_snapshots.py index d4cc65e964..ef2dd38c47 100644 --- a/tests_metricflow/generate_snapshots.py +++ b/tests_metricflow/generate_snapshots.py @@ -64,7 +64,7 @@ class MetricFlowTestCredentialSet(FrozenBaseModel): # noqa: D101 @dataclass(frozen=True) -class MetricFlowTestConfiguration: # noqa: D101 +class MetricFlowEngineConfiguration: # noqa: D101 engine: SqlEngine credential_set: MetricFlowTestCredentialSet @@ -79,33 +79,33 @@ class MetricFlowTestCredentialSetForAllEngines(FrozenBaseModel): # noqa: D101 trino: MetricFlowTestCredentialSet @property - def as_configurations(self) -> Sequence[MetricFlowTestConfiguration]: # noqa: D102 + def as_configurations(self) -> Sequence[MetricFlowEngineConfiguration]: # noqa: D102 return ( - MetricFlowTestConfiguration( + MetricFlowEngineConfiguration( engine=SqlEngine.DUCKDB, credential_set=self.duck_db, ), - MetricFlowTestConfiguration( + MetricFlowEngineConfiguration( engine=SqlEngine.REDSHIFT, credential_set=self.redshift, ), - MetricFlowTestConfiguration( + MetricFlowEngineConfiguration( engine=SqlEngine.SNOWFLAKE, credential_set=self.snowflake, ), - MetricFlowTestConfiguration( + MetricFlowEngineConfiguration( engine=SqlEngine.BIGQUERY, credential_set=self.big_query, ), - MetricFlowTestConfiguration( + MetricFlowEngineConfiguration( engine=SqlEngine.DATABRICKS, credential_set=self.databricks, ), - MetricFlowTestConfiguration( + MetricFlowEngineConfiguration( engine=SqlEngine.POSTGRES, credential_set=self.postgres, ), - MetricFlowTestConfiguration( + MetricFlowEngineConfiguration( engine=SqlEngine.TRINO, credential_set=self.trino, ), @@ -119,7 +119,7 @@ def run_command(command: str) -> None: # noqa: D103 raise RuntimeError(f"Error running command: {command}") -def set_engine_env_variables(test_configuration: MetricFlowTestConfiguration) -> None: +def set_engine_env_variables(test_configuration: MetricFlowEngineConfiguration) -> None: """Set connection env variables dynamically for the engine being used. Requires MF_TEST_ENGINE_CREDENTIALS env variable to be set with creds for all engines. @@ -137,7 +137,7 @@ def set_engine_env_variables(test_configuration: MetricFlowTestConfiguration) -> os.environ["MF_SQL_ENGINE_PASSWORD"] = test_configuration.credential_set.engine_password -def run_tests(test_configuration: MetricFlowTestConfiguration) -> None: # noqa: D103 +def run_tests(test_configuration: MetricFlowEngineConfiguration) -> None: # noqa: D103 set_engine_env_variables(test_configuration) if test_configuration.engine is SqlEngine.DUCKDB: diff --git a/tests_metricflow/populate_persistent_source_schemas.py b/tests_metricflow/populate_persistent_source_schemas.py index b88248934d..f2afed86c7 100644 --- a/tests_metricflow/populate_persistent_source_schemas.py +++ b/tests_metricflow/populate_persistent_source_schemas.py @@ -9,7 +9,7 @@ from metricflow.protocols.sql_client import SqlEngine from tests_metricflow.generate_snapshots import ( - MetricFlowTestConfiguration, + MetricFlowEngineConfiguration, run_cli, run_command, set_engine_env_variables, @@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) -def populate_schemas(test_configuration: MetricFlowTestConfiguration) -> None: # noqa: D103 +def populate_schemas(test_configuration: MetricFlowEngineConfiguration) -> None: # noqa: D103 set_engine_env_variables(test_configuration) if test_configuration.engine is SqlEngine.DUCKDB or test_configuration.engine is SqlEngine.POSTGRES: From 7f5bdf01bd44995eef28a21e5c59e01345676a09 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 10 Dec 2024 18:02:31 -0800 Subject: [PATCH 2/2] /* PR_START p--misc 04 */ Fix argument name in `_create_data_sets`. --- tests_metricflow/fixtures/manifest_fixtures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests_metricflow/fixtures/manifest_fixtures.py b/tests_metricflow/fixtures/manifest_fixtures.py index 7bcde44470..d5f2026b1e 100644 --- a/tests_metricflow/fixtures/manifest_fixtures.py +++ b/tests_metricflow/fixtures/manifest_fixtures.py @@ -234,7 +234,7 @@ def _data_set_to_read_nodes( @staticmethod def _create_data_sets( - multihop_semantic_manifest_lookup: SemanticManifestLookup, + semantic_manifest_lookup: SemanticManifestLookup, ) -> OrderedDict[str, SemanticModelDataSet]: """Convert the SemanticModels in the model to SqlDataSets. @@ -244,11 +244,11 @@ def _create_data_sets( # Use ordered dict and sort by name to get consistency when running tests. data_sets = OrderedDict() - semantic_models: Sequence[SemanticModel] = multihop_semantic_manifest_lookup.semantic_manifest.semantic_models + semantic_models: Sequence[SemanticModel] = semantic_manifest_lookup.semantic_manifest.semantic_models semantic_models = sorted(semantic_models, key=lambda x: x.name) converter = SemanticModelToDataSetConverter( - column_association_resolver=DunderColumnAssociationResolver(multihop_semantic_manifest_lookup) + column_association_resolver=DunderColumnAssociationResolver(semantic_manifest_lookup) ) for semantic_model in semantic_models: