From 73461b3eb10e84b171419a8c9bea1266ceea0f12 Mon Sep 17 00:00:00 2001 From: Devon Fulcher <24593113+DevonFulcher@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:33:08 -0500 Subject: [PATCH 1/6] Downgrade Pydantic in dev-env --- .tool-versions | 1 + pyproject.toml | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..c06f9879 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +python 3.8.20 diff --git a/pyproject.toml b/pyproject.toml index 2fc2a9af..1e661106 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,9 +6,7 @@ readme = "README.md" requires-python = ">=3.8" license = "Apache-2.0" keywords = [] -authors = [ - { name = "dbt Labs", email = "info@dbtlabs.com" }, -] +authors = [{ name = "dbt Labs", email = "info@dbtlabs.com" }] classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: Apache Software License", @@ -57,6 +55,7 @@ all = ["pre-commit run --all-files"] [tool.hatch.envs.dev-env] description = "Env for running development commands like pytest / pre-commit" +python = "3.8" dependencies = [ "pytest>=7.3,<8", "pytest-xdist>=3.2,<4", @@ -66,7 +65,8 @@ dependencies = [ "isort>=5.12,<6", "black>=23.3,<24", "ruff==0.0.260", - "mypy>=1.3,<2", + "mypy==1.6.1", + "pydantic>=1.10,<2", # The types in this codebase with mypy checker are only compatible with pydantic 1 "pytest>=7.3,<8", "types-Jinja2>=2.11,<3", "types-jsonschema>=4.17,<5", @@ -86,7 +86,7 @@ ignore = [ # Missing docstring in public module -- often docs handled within classes "D100", # Missing docstring in public package -- often docs handled within files not __init__.py - "D104" + "D104", ] # Let ruff autofix these errors. # F401 - Unused imports. From e02bb50c592b270d430485fb14bd4d59c061cfad Mon Sep 17 00:00:00 2001 From: Devon Fulcher <24593113+DevonFulcher@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:49:34 -0500 Subject: [PATCH 2/6] changie --- .changes/unreleased/Under the Hood-20241010-164927.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20241010-164927.yaml diff --git a/.changes/unreleased/Under the Hood-20241010-164927.yaml b/.changes/unreleased/Under the Hood-20241010-164927.yaml new file mode 100644 index 00000000..17b2a295 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20241010-164927.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Downgrade Pydantic in dev-env +time: 2024-10-10T16:49:27.844308-05:00 +custom: + Author: DevonFulcher + Issue: None From 38faac78bdf77b431b6f1bb66a6f18de7a14a5e7 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 11 Oct 2024 13:28:18 -0700 Subject: [PATCH 3/6] Add docstring for DSI pydantic shim --- dsi_pydantic_shim.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dsi_pydantic_shim.py b/dsi_pydantic_shim.py index 3ea00720..9c333cbf 100644 --- a/dsi_pydantic_shim.py +++ b/dsi_pydantic_shim.py @@ -1,3 +1,13 @@ +"""Shim to allow support for both Pydantic 1 and Pydantic 2. + +DSI must support both major versions of Pydantic because dbt-core depends on DSI. dbt-core users might be using an +environment with either version, and we can't restrict them to one or the other. Here, we essentially import all +Pydantic objects from version 1. Throughout the repo, we import those objects from this file instead of from Pydantic +directly, meaning that we essentially only use Pydantic 1 in this repo, but without forcing that restriction on dbt +users. The development environment for this repo should be pinned to Pydantic 1 to ensure devs get appropriate type +hints. +""" + from importlib.metadata import version pydantic_version = version("pydantic") From b1766d7cf7071df3daaf7066b2f3144136809e48 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 11 Oct 2024 13:29:54 -0700 Subject: [PATCH 4/6] Don't pin to python 3.8 --- .tool-versions | 1 - pyproject.toml | 1 - 2 files changed, 2 deletions(-) delete mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index c06f9879..00000000 --- a/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -python 3.8.20 diff --git a/pyproject.toml b/pyproject.toml index 1e661106..7710213b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,6 @@ all = ["pre-commit run --all-files"] [tool.hatch.envs.dev-env] description = "Env for running development commands like pytest / pre-commit" -python = "3.8" dependencies = [ "pytest>=7.3,<8", "pytest-xdist>=3.2,<4", From e80f3035472d2184cdc561f9f23d2b9c48b80006 Mon Sep 17 00:00:00 2001 From: Devon Fulcher <24593113+DevonFulcher@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:54:59 -0500 Subject: [PATCH 5/6] Remove cumulative metrics deprecation warning --- .../validations/metrics.py | 19 +------------------ tests/validations/test_metrics.py | 10 +++++----- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/dbt_semantic_interfaces/validations/metrics.py b/dbt_semantic_interfaces/validations/metrics.py index 41649c2d..f0eb0dff 100644 --- a/dbt_semantic_interfaces/validations/metrics.py +++ b/dbt_semantic_interfaces/validations/metrics.py @@ -1,5 +1,5 @@ import traceback -from typing import Dict, Generic, List, Optional, Sequence, Set, Tuple +from typing import Dict, Generic, List, Optional, Sequence, Tuple from dbt_semantic_interfaces.call_parameter_sets import FilterCallParameterSets from dbt_semantic_interfaces.errors import ParsingException @@ -48,7 +48,6 @@ class CumulativeMetricRule(SemanticManifestValidationRule[SemanticManifestT], Ge def validate_manifest(semantic_manifest: SemanticManifestT) -> Sequence[ValidationIssue]: # noqa: D issues: List[ValidationIssue] = [] - metrics_using_old_params: Set[str] = set() for metric in semantic_manifest.metrics or []: if metric.type != MetricType.CUMULATIVE: continue @@ -60,9 +59,6 @@ def validate_manifest(semantic_manifest: SemanticManifestT) -> Sequence[Validati for field in ("window", "grain_to_date"): type_params_field_value = getattr(metric.type_params, field) - # Warn that the old type_params structure has been deprecated. - if type_params_field_value: - metrics_using_old_params.add(metric.name) # Warn that window or grain_to_date is mismatched across params. cumulative_type_params_field_value = ( @@ -115,19 +111,6 @@ def validate_manifest(semantic_manifest: SemanticManifestT) -> Sequence[Validati extra_detail="".join(traceback.format_tb(e.__traceback__)), ) ) - if metrics_using_old_params: - issues.append( - ValidationWarning( - context=metric_context, - message=( - "Cumulative fields `type_params.window` and `type_params.grain_to_date` have been moved and " - "will soon be deprecated. Please nest those values under " - "`type_params.cumulative_type_params.window` and " - "`type_params.cumulative_type_params.grain_to_date`. Metrics using old fields: " - f"{sorted(metrics_using_old_params)}" - ), - ) - ) return issues diff --git a/tests/validations/test_metrics.py b/tests/validations/test_metrics.py index 5439331f..efafeef0 100644 --- a/tests/validations/test_metrics.py +++ b/tests/validations/test_metrics.py @@ -66,8 +66,10 @@ def check_error_in_issues(error_substrings: List[str], issues: Tuple[ValidationI for expected_str in error_substrings: if not any(actual_str.as_readable_str().find(expected_str) != -1 for actual_str in issues): missing_error_strings.add(expected_str) - assert len(missing_error_strings) == 0, "Failed to match one or more expected issues: " - f"{missing_error_strings} in {set([x.as_readable_str() for x in issues])}" + assert len(missing_error_strings) == 0, ( + "Failed to match one or more expected issues: " + + f"{missing_error_strings} in {set([x.as_readable_str() for x in issues])}" + ) def test_metric_no_time_dim_dim_only_source() -> None: # noqa:D @@ -742,13 +744,11 @@ def test_cumulative_metrics() -> None: # noqa: D ) build_issues = validation_results.all_issues - assert len(build_issues) == 4 + assert len(build_issues) == 3 expected_substrings = [ "Both window and grain_to_date set for cumulative metric. Please set one or the other.", "Got differing values for `window`", "Got differing values for `grain_to_date`", - "Cumulative fields `type_params.window` and `type_params.grain_to_date` have been moved", - str(sorted({"what_a_metric", "dis_bad", "woooooo", "metric1", "metric2"})), ] check_error_in_issues(error_substrings=expected_substrings, issues=build_issues) From a956f47773db78e699a88be66f927d1bcb88ab9f Mon Sep 17 00:00:00 2001 From: Devon Fulcher <24593113+DevonFulcher@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:00:10 -0500 Subject: [PATCH 6/6] changie --- .changes/unreleased/Under the Hood-20241015-110006.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20241015-110006.yaml diff --git a/.changes/unreleased/Under the Hood-20241015-110006.yaml b/.changes/unreleased/Under the Hood-20241015-110006.yaml new file mode 100644 index 00000000..ab7899e3 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20241015-110006.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Remove cumulative metric type param deprecation warning +time: 2024-10-15T11:00:06.108655-05:00 +custom: + Author: DevonFulcher + Issue: None