diff --git a/metricflow-semantics/metricflow_semantics/mf_logging/pretty_print.py b/metricflow-semantics/metricflow_semantics/mf_logging/pretty_print.py index 330d9e1cca..3373a1c20b 100644 --- a/metricflow-semantics/metricflow_semantics/mf_logging/pretty_print.py +++ b/metricflow-semantics/metricflow_semantics/mf_logging/pretty_print.py @@ -39,7 +39,9 @@ def _is_pydantic_base_model(obj: Any): # type:ignore # Checking the attribute as the BaseModel check fails for newer version of Pydantic. return isinstance(obj, BaseModel) or hasattr(obj, "__config__") - def _handle_sequence_obj(self, list_like_obj: Union[list, tuple], remaining_line_width: Optional[int]) -> str: + def _handle_sequence_obj( + self, list_like_obj: Union[list, tuple, set, frozenset], remaining_line_width: Optional[int] + ) -> str: """Pretty prints a sequence object i.e. list or tuple. Args: @@ -55,6 +57,10 @@ def _handle_sequence_obj(self, list_like_obj: Union[list, tuple], remaining_line elif isinstance(list_like_obj, tuple): left_enclose_str = "(" right_enclose_str = ")" + elif isinstance(list_like_obj, set) or isinstance(list_like_obj, frozenset): + left_enclose_str = f"{type(list_like_obj).__name__}(" + right_enclose_str = ")" + list_like_obj = sorted(list_like_obj) else: raise RuntimeError(f"Unhandled type: {type(list_like_obj)}") @@ -317,7 +323,7 @@ def _handle_any_obj(self, obj: Any, remaining_line_width: Optional[int]) -> str: if isinstance(obj, Enum): return obj.name - if isinstance(obj, (list, tuple)): + if isinstance(obj, (list, tuple, set, frozenset)): return self._handle_sequence_obj(obj, remaining_line_width=remaining_line_width) if isinstance(obj, dict): diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__accumulate_last_2_months_metric__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__accumulate_last_2_months_metric__result.txt index 310e9c9004..cf064eae20 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__accumulate_last_2_months_metric__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__accumulate_last_2_months_metric__result.txt @@ -13,7 +13,7 @@ GroupByItemResolution( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset(METRIC_TIME,), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__derived_metric_with_different_parent_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__derived_metric_with_different_parent_time_grains__result.txt index a151d9b75c..f0c857239b 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__derived_metric_with_different_parent_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__derived_metric_with_different_parent_time_grains__result.txt @@ -25,7 +25,9 @@ GroupByItemResolution( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), @@ -63,7 +65,9 @@ GroupByItemResolution( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=YEAR, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__derived_metric_with_same_parent_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__derived_metric_with_same_parent_time_grains__result.txt index 310e9c9004..cf064eae20 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__derived_metric_with_same_parent_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__derived_metric_with_same_parent_time_grains__result.txt @@ -13,7 +13,7 @@ GroupByItemResolution( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset(METRIC_TIME,), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__metrics_with_different_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__metrics_with_different_time_grains__result.txt index 9778252906..3bff553fff 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__metrics_with_different_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__metrics_with_different_time_grains__result.txt @@ -22,7 +22,9 @@ GroupByItemResolution( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), @@ -58,7 +60,9 @@ GroupByItemResolution( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=YEAR, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__metrics_with_same_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__metrics_with_same_time_grains__result.txt index 310e9c9004..cf064eae20 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__metrics_with_same_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__metrics_with_same_time_grains__result.txt @@ -13,7 +13,7 @@ GroupByItemResolution( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset(METRIC_TIME,), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__no_metrics__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__no_metrics__result.txt index 057b0dfe18..df898232b9 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__no_metrics__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__no_metrics__result.txt @@ -10,7 +10,7 @@ GroupByItemResolution( LinkableDimension( element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset(METRIC_TIME,), time_granularity=DAY, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__simple_metric__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__simple_metric__result.txt index 310e9c9004..cf064eae20 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__simple_metric__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_matching_item_for_filters.py/GroupByItemResolution/test_ambiguous_metric_time_in_query_filter__simple_metric__result.txt @@ -13,7 +13,7 @@ GroupByItemResolution( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset(METRIC_TIME,), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_derived_metrics_with_common_filtered_metric__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_derived_metrics_with_common_filtered_metric__result.txt index e4e1f4ce43..3e6c6f9d36 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_derived_metrics_with_common_filtered_metric__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_derived_metrics_with_common_filtered_metric__result.txt @@ -35,7 +35,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), @@ -91,7 +93,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_filter__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_filter__result.txt index 063f27b837..c164fe721c 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_filter__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_filter__result.txt @@ -54,7 +54,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), @@ -92,7 +94,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=YEAR, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_input_filter__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_input_filter__result.txt index 8e6b7a0ca8..81f9662c07 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_input_filter__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_input_filter__result.txt @@ -55,7 +55,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), @@ -95,7 +97,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=YEAR, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_filter__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_filter__result.txt index 60b59c8d79..cea6f25ce6 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_filter__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_filter__result.txt @@ -35,7 +35,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_input_filter__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_input_filter__result.txt index cc155e70a5..9b91b8ec43 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_input_filter__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_input_filter__result.txt @@ -35,7 +35,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__accumulate_last_2_months_metric__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__accumulate_last_2_months_metric__result.txt index 7d77ed1031..61e476d18b 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__accumulate_last_2_months_metric__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__accumulate_last_2_months_metric__result.txt @@ -35,7 +35,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_different_parent_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_different_parent_time_grains__result.txt index 58383f8a08..e305e2ef23 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_different_parent_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_different_parent_time_grains__result.txt @@ -54,7 +54,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), @@ -92,7 +94,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=YEAR, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_same_parent_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_same_parent_time_grains__result.txt index df8b92b453..16dc193596 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_same_parent_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_same_parent_time_grains__result.txt @@ -35,7 +35,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_different_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_different_time_grains__result.txt index 2cc7ddb651..265a03b436 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_different_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_different_time_grains__result.txt @@ -56,7 +56,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), @@ -92,7 +94,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=YEAR, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_same_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_same_time_grains__result.txt index 08165c1164..45cdaa6f78 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_same_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_same_time_grains__result.txt @@ -38,7 +38,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__simple_metric__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__simple_metric__result.txt index 30917c4241..23e0edb603 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__simple_metric__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__simple_metric__result.txt @@ -35,7 +35,9 @@ FilterSpecResolutionLookUp( ), element_name='metric_time', dimension_type=TIME, - properties=frozenset({}), + properties=frozenset( + METRIC_TIME, + ), time_granularity=MONTH, ), ),