From 2bfed4634ca1be219325727c71d1a8981e5bbc61 Mon Sep 17 00:00:00 2001 From: tlento Date: Thu, 10 Aug 2023 10:43:45 -0700 Subject: [PATCH 1/3] Relax GraphViz version specification Our use of GraphViz is compatible with a much broader range than originally specified. This has been tested in the CLI and we can render plans with 0.20.1. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d7bea5715c..04da085c8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ dependencies = [ "click>=7.1.2, <8.1.4", "dbt-core~=1.6.0", "dbt-semantic-interfaces~=0.2.0", - "graphviz==0.18.2", + "graphviz>=0.18.2, <0.21", "halo~=0.0.31", "jsonschema==3.2.0", "more-itertools==8.10.0", From fc31fcd48c3b2302ce5875cf393a8c68f4f35d73 Mon Sep 17 00:00:00 2001 From: tlento Date: Thu, 10 Aug 2023 11:16:46 -0700 Subject: [PATCH 2/3] Relax version pins where possible Several packages have strict version pins that are not necessary, as our usage is compatible with a broad range of versions. These updated version ranges all appear to be safe with MetricFlow's current usage and dependency requirements. --- .changes/unreleased/Dependencies-20230810-112931.yaml | 6 ++++++ pyproject.toml | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/Dependencies-20230810-112931.yaml diff --git a/.changes/unreleased/Dependencies-20230810-112931.yaml b/.changes/unreleased/Dependencies-20230810-112931.yaml new file mode 100644 index 0000000000..4a71b10470 --- /dev/null +++ b/.changes/unreleased/Dependencies-20230810-112931.yaml @@ -0,0 +1,6 @@ +kind: Dependencies +body: Relax version pins for MetricFlow dependencies +time: 2023-08-10T11:29:31.987305-07:00 +custom: + Author: tlento + PR: "720" diff --git a/pyproject.toml b/pyproject.toml index 04da085c8e..6ebe34fa06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ ] dependencies = [ "Jinja2>=2.11.3", - "MarkupSafe==2.0.1", + "MarkupSafe==2.0.1", # pandas implicitly requires this version "PyYAML~=6.0", "click>=7.1.2, <8.1.4", "dbt-core~=1.6.0", @@ -34,12 +34,12 @@ dependencies = [ "graphviz>=0.18.2, <0.21", "halo~=0.0.31", "jsonschema==3.2.0", - "more-itertools==8.10.0", + "more-itertools>=8.10.0, <10.2.0", "numpy>=1.22.2", "pandas~=1.5.0", "pydantic~=1.10.0", - "python-dateutil==2.8.2", - "rapidfuzz==3.0.0", + "python-dateutil~=2.8.2", + "rapidfuzz~=3.0", "ruamel.yaml~=0.17.21", "rudder-sdk-python~=1.0.3", "tabulate~=0.8.9", From 39c9cde7593e8e81b7cd59d6294f0351dee13485 Mon Sep 17 00:00:00 2001 From: tlento Date: Thu, 10 Aug 2023 11:24:10 -0700 Subject: [PATCH 3/3] Remove jsonschema dependencies MetricFlow's jsonschema dependency was a holdover from the days when it was a monolithic package supporting both open source and Transform internal use cases. The last remaining dependency was jsonschema parsing support for some Transform-specific attributes, which are no longer in use. This removes all explicit jsonschema dependencies, instead relying on dbt-semantic-interfaces for managing the relevant package installation requirements. --- metricflow/model/parsing/__init__.py | 0 metricflow/model/parsing/schemas_internal.py | 111 ------------------- pyproject.toml | 2 - 3 files changed, 113 deletions(-) delete mode 100644 metricflow/model/parsing/__init__.py delete mode 100644 metricflow/model/parsing/schemas_internal.py diff --git a/metricflow/model/parsing/__init__.py b/metricflow/model/parsing/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/metricflow/model/parsing/schemas_internal.py b/metricflow/model/parsing/schemas_internal.py deleted file mode 100644 index b6cdf64521..0000000000 --- a/metricflow/model/parsing/schemas_internal.py +++ /dev/null @@ -1,111 +0,0 @@ -from __future__ import annotations - -from typing import Any, Dict - -from dbt_semantic_interfaces.parsing.schema_validator import SchemaValidator -from dbt_semantic_interfaces.parsing.schemas import ( - aggregation_type_params_schema, - dimension_schema, - dimension_type_params_schema, - entity_schema, - measure_schema, - metric_input_measure_schema, - metric_input_schema, - metric_schema, - metric_type_params_schema, - node_relation_schema, - non_additive_dimension_schema, - semantic_model_schema, - validity_params_schema, -) -from jsonschema import RefResolver - - -def add_transform_metadata_fields_to_spec(spec: Dict[str, Any]) -> None: # type: ignore[misc] - """Adds transform metadata fields a spec.""" - properties = spec["properties"] - transform_metadata_fields = { - "description": {"type": "string"}, - "owners": { - "type": "array", - "items": {"type": "string"}, - }, - "display_name": {"type": "string"}, - "tier": {"type": ["string", "integer"]}, - } - - for k, v in transform_metadata_fields.items(): - if k in properties: - raise RuntimeError(f"Spec with id: {spec['$id']} contains transform metadata field: {k}") - - properties[k] = v - - -def add_locked_metadata_to_spec(spec: Dict[str, Any]) -> None: # type: ignore[misc] - """Adds locked metadata field to a spec.""" - properties = spec["properties"] - transform_metadata_fields = { - "locked_metadata": {"$ref": "locked_metadata"}, - } - - for k, v in transform_metadata_fields.items(): - if k in properties: - raise RuntimeError(f"Spec with id: {spec['$id']} contains transform metadata field: {k}") - - properties[k] = v - - -# Sub-object schemas -locked_metadata_schema = { - "$id": "locked_metadata", - "type": "object", - "properties": { - "value_format": {"type": "string"}, - "description": {"type": "string"}, - "display_name": {"type": "string"}, - "tier": {"type": ["string", "integer"]}, - "increase_is_good": {"type": "boolean"}, - "tags": { - "type": "array", - "items": {"type": "string"}, - }, - "private": {"type": "boolean"}, - "unit": {"type": "string"}, - }, - "additionalProperties": False, -} - - -# Add transform metadata fields to top level objects (metric, semantic model, derived entity) -add_transform_metadata_fields_to_spec(dimension_schema) -add_transform_metadata_fields_to_spec(measure_schema) -add_transform_metadata_fields_to_spec(entity_schema) - -add_transform_metadata_fields_to_spec(metric_schema) -add_locked_metadata_to_spec(metric_schema) - -add_transform_metadata_fields_to_spec(semantic_model_schema) - - -schema_store = { - # Top level schemas - metric_schema["$id"]: metric_schema, - semantic_model_schema["$id"]: semantic_model_schema, - # Sub-object schemas - metric_input_measure_schema["$id"]: metric_input_measure_schema, - metric_type_params_schema["$id"]: metric_type_params_schema, - locked_metadata_schema["$id"]: locked_metadata_schema, - entity_schema["$id"]: entity_schema, - measure_schema["$id"]: measure_schema, - dimension_schema["$id"]: dimension_schema, - validity_params_schema["$id"]: validity_params_schema, - dimension_type_params_schema["$id"]: dimension_type_params_schema, - aggregation_type_params_schema["$id"]: aggregation_type_params_schema, - non_additive_dimension_schema["$id"]: non_additive_dimension_schema, - metric_input_schema["$id"]: metric_input_schema, - node_relation_schema["$id"]: node_relation_schema, -} - -resolver = RefResolver.from_schema(schema=metric_schema, store=schema_store) -semantic_model_validator = SchemaValidator(semantic_model_schema, resolver=resolver) -metric_validator = SchemaValidator(metric_schema, resolver=resolver) diff --git a/pyproject.toml b/pyproject.toml index 6ebe34fa06..c11e6a9679 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,6 @@ dependencies = [ "dbt-semantic-interfaces~=0.2.0", "graphviz>=0.18.2, <0.21", "halo~=0.0.31", - "jsonschema==3.2.0", "more-itertools>=8.10.0, <10.2.0", "numpy>=1.22.2", "pandas~=1.5.0", @@ -62,7 +61,6 @@ dev-packages = [ "pytest-xdist~=3.2.1", "pytest~=7.1.1", "types-PyYAML", - "types-jsonschema", "types-python-dateutil", "types-tabulate", ]