From 967c21e0cb4fe46a01fe8f4409cdd55513a14912 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Tue, 15 Oct 2024 13:11:12 -0400 Subject: [PATCH] updated generate snapshot script to update snapshots in metricflow-semantics --- tests_metricflow/generate_snapshots.py | 52 ++++++++++++++------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/tests_metricflow/generate_snapshots.py b/tests_metricflow/generate_snapshots.py index a67c685725..932c6641ad 100644 --- a/tests_metricflow/generate_snapshots.py +++ b/tests_metricflow/generate_snapshots.py @@ -44,7 +44,6 @@ from dataclasses import dataclass from typing import Callable, Optional, Sequence -from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.implementations.base import FrozenBaseModel from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat @@ -55,6 +54,7 @@ TEST_DIRECTORY = "tests_metricflow" +MF_SEMANTICS_TEST_DIRECTORY = "metricflow-semantics/tests_metricflow_semantics" class MetricFlowTestCredentialSet(FrozenBaseModel): # noqa: D101 @@ -142,29 +142,33 @@ def run_tests(test_configuration: MetricFlowTestConfiguration) -> None: # noqa: if test_configuration.engine is SqlEngine.DUCKDB: # DuckDB is fast, so generate all snapshots, including the engine-agnostic ones run_command(f"pytest -x -vv -n 4 --overwrite-snapshots -k 'not itest' {TEST_DIRECTORY}") - elif ( - test_configuration.engine is SqlEngine.REDSHIFT - or test_configuration.engine is SqlEngine.SNOWFLAKE - or test_configuration.engine is SqlEngine.BIGQUERY - or test_configuration.engine is SqlEngine.DATABRICKS - or test_configuration.engine is SqlEngine.POSTGRES - or test_configuration.engine is SqlEngine.TRINO - ): - engine_name = test_configuration.engine.value.lower() - os.environ["MF_TEST_ADAPTER_TYPE"] = engine_name - hatch_env = f"{engine_name}-env" - use_persistent_source_schema = ( - test_configuration.engine != SqlEngine.POSTGRES and test_configuration.engine != SqlEngine.TRINO - ) - run_command( - f"hatch -v run {hatch_env}:pytest -x -vv -n 4 " - f"--overwrite-snapshots" - f"{' --use-persistent-source-schema' if use_persistent_source_schema else ''}" - f" -m '{SQL_ENGINE_SNAPSHOT_MARKER_NAME}' " - f"{TEST_DIRECTORY}" - ) - else: - assert_values_exhausted(test_configuration.engine) + + # Run snapshots changes for metricflow-semantics + # these are not dialect specific, so only need to run once + run_command(f"pytest -x -vv -n 4 --overwrite-snapshots {MF_SEMANTICS_TEST_DIRECTORY}") + # elif ( + # test_configuration.engine is SqlEngine.REDSHIFT + # or test_configuration.engine is SqlEngine.SNOWFLAKE + # or test_configuration.engine is SqlEngine.BIGQUERY + # or test_configuration.engine is SqlEngine.DATABRICKS + # or test_configuration.engine is SqlEngine.POSTGRES + # or test_configuration.engine is SqlEngine.TRINO + # ): + # engine_name = test_configuration.engine.value.lower() + # os.environ["MF_TEST_ADAPTER_TYPE"] = engine_name + # hatch_env = f"{engine_name}-env" + # use_persistent_source_schema = ( + # test_configuration.engine != SqlEngine.POSTGRES and test_configuration.engine != SqlEngine.TRINO + # ) + # run_command( + # f"hatch -v run {hatch_env}:pytest -x -vv -n 4 " + # f"--overwrite-snapshots" + # f"{' --use-persistent-source-schema' if use_persistent_source_schema else ''}" + # f" -m '{SQL_ENGINE_SNAPSHOT_MARKER_NAME}' " + # f"{TEST_DIRECTORY}" + # ) + # else: + # assert_values_exhausted(test_configuration.engine) def run_cli(function_to_run: Callable) -> None: # noqa: D103