From 0645e54f362d85a616a71a7c996430e775a366f1 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 25 Sep 2024 13:01:33 -0700 Subject: [PATCH] Custom granularity cleanup --- .../metricflow_semantics/model/semantic_manifest_lookup.py | 6 +++--- .../metricflow_semantics/naming/dunder_scheme.py | 2 +- .../query/validation_rules/metric_time_requirements.py | 2 +- metricflow/plan_conversion/dataflow_to_sql.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/model/semantic_manifest_lookup.py b/metricflow-semantics/metricflow_semantics/model/semantic_manifest_lookup.py index 03af5406fc..7f12180696 100644 --- a/metricflow-semantics/metricflow_semantics/model/semantic_manifest_lookup.py +++ b/metricflow-semantics/metricflow_semantics/model/semantic_manifest_lookup.py @@ -17,14 +17,14 @@ class SemanticManifestLookup: def __init__(self, semantic_manifest: SemanticManifest) -> None: # noqa: D107 self._semantic_manifest = semantic_manifest self._time_spine_sources = TimeSpineSource.build_standard_time_spine_sources(semantic_manifest) - self._custom_granularities = TimeSpineSource.build_custom_granularities(list(self._time_spine_sources.values())) + self.custom_granularities = TimeSpineSource.build_custom_granularities(list(self._time_spine_sources.values())) self._semantic_model_lookup = SemanticModelLookup( - model=semantic_manifest, custom_granularities=self._custom_granularities + model=semantic_manifest, custom_granularities=self.custom_granularities ) self._metric_lookup = MetricLookup( semantic_manifest=self._semantic_manifest, semantic_model_lookup=self._semantic_model_lookup, - custom_granularities=self._custom_granularities, + custom_granularities=self.custom_granularities, ) @property diff --git a/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py b/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py index 5cbeb1bfe8..df3e66879e 100644 --- a/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py +++ b/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py @@ -78,7 +78,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes # At this point, len(input_str_parts) >= 2 valid_granularity_names = {granularity.value for granularity in TimeGranularity}.union( - set(semantic_manifest_lookup._custom_granularities.keys()) + set(semantic_manifest_lookup.custom_granularities.keys()) ) suffix = input_str_parts[-1] time_granularity_name = suffix if suffix in valid_granularity_names else None diff --git a/metricflow-semantics/metricflow_semantics/query/validation_rules/metric_time_requirements.py b/metricflow-semantics/metricflow_semantics/query/validation_rules/metric_time_requirements.py index 9d67dce22c..572b6f0ee7 100644 --- a/metricflow-semantics/metricflow_semantics/query/validation_rules/metric_time_requirements.py +++ b/metricflow-semantics/metricflow_semantics/query/validation_rules/metric_time_requirements.py @@ -39,7 +39,7 @@ def __init__(self, manifest_lookup: SemanticManifestLookup) -> None: # noqa: D1 TimeDimensionSpec.generate_possible_specs_for_time_dimension( time_dimension_reference=TimeDimensionReference(element_name=METRIC_TIME_ELEMENT_NAME), entity_links=(), - custom_granularities=self._manifest_lookup._custom_granularities, + custom_granularities=self._manifest_lookup.custom_granularities, ) ) diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index d00a41d53e..64b8ff5561 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -1413,10 +1413,10 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> SqlDataSet ), ) - def _get_time_spine_for_custom_granularity(self, custom_granularity: str) -> TimeSpineSource: - time_spine_source = self._custom_granularity_time_spine_sources.get(custom_granularity) + def _get_time_spine_for_custom_granularity(self, custom_granularity_name: str) -> TimeSpineSource: + time_spine_source = self._custom_granularity_time_spine_sources.get(custom_granularity_name) assert time_spine_source, ( - f"Custom granularity {custom_granularity} does not not exist in time spine sources. " + f"Custom granularity {custom_granularity_name} does not not exist in time spine sources. " f"Available custom granularities: {list(self._custom_granularity_time_spine_sources.keys())}" ) return time_spine_source