Skip to content

Commit

Permalink
/* PR_START p--cte 13 */ Rename mf_pformat_many-> mf_pformat_dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Nov 11, 2024
1 parent ab1a464 commit ab53d7e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing_extensions import override

from metricflow_semantics.mf_logging.pretty_print import mf_pformat_many
from metricflow_semantics.mf_logging.pretty_print import mf_pformat_dict


class LazyFormat:
Expand Down Expand Up @@ -52,7 +52,7 @@ def _str_value(self) -> str:
message = self._message()
else:
message = self._message
return mf_pformat_many(message, self._kwargs, preserve_raw_strings=True)
return mf_pformat_dict(message, self._kwargs, preserve_raw_strings=True)

@override
def __str__(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def mf_pformat( # type: ignore
return str(obj)


def mf_pformat_many( # type: ignore
def mf_pformat_dict( # type: ignore
description: str,
obj_dict: Dict[str, Any],
max_line_length: int = 120,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from metricflow_semantics.mf_logging.formatting import indent
from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat
from metricflow_semantics.mf_logging.pretty_print import mf_pformat, mf_pformat_many
from metricflow_semantics.mf_logging.pretty_print import mf_pformat, mf_pformat_dict
from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow_semantics.model.semantics.element_filter import LinkableElementFilter
from metricflow_semantics.query.group_by_item.candidate_push_down.group_by_item_candidate import GroupByItemCandidateSet
Expand Down Expand Up @@ -82,7 +82,7 @@ def __post_init__(self) -> None: # noqa: D105
# If there are errors, there shouldn't be any candidate sets.
assert (not self.issue_set.has_errors and not self.candidate_set.is_empty) or (
self.issue_set.has_errors and self.candidate_set.is_empty
), mf_pformat_many(
), mf_pformat_dict(
"candidate_set / issue_set mismatch:", {"candidate_set": self.candidate_set, "issue_set": self.issue_set}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dbt_semantic_interfaces.references import MeasureReference, MetricReference, SemanticModelReference

from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat
from metricflow_semantics.mf_logging.pretty_print import mf_pformat, mf_pformat_many
from metricflow_semantics.mf_logging.pretty_print import mf_pformat, mf_pformat_dict
from metricflow_semantics.mf_logging.runtime import log_runtime
from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow_semantics.model.semantic_model_derivation import SemanticModelDerivation
Expand Down Expand Up @@ -557,7 +557,7 @@ def _resolve_query(self, resolver_input_for_query: ResolverInputForQuery) -> Met
if len(models_not_in_manifest) > 0:
logger.error(
LazyFormat(
lambda: mf_pformat_many(
lambda: mf_pformat_dict(
"Semantic references that aren't in the manifest were found in the set used in "
"a query. This is a bug, and to avoid potential issues, they will be filtered out.",
{"models_not_in_manifest": models_not_in_manifest},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dbt_semantic_interfaces.type_enums import DimensionType
from metricflow_semantics.mf_logging.formatting import indent
from metricflow_semantics.mf_logging.pretty_formattable import MetricFlowPrettyFormattable
from metricflow_semantics.mf_logging.pretty_print import mf_pformat, mf_pformat_many
from metricflow_semantics.mf_logging.pretty_print import mf_pformat, mf_pformat_dict
from metricflow_semantics.test_helpers.metric_time_dimension import MTD_SPEC_DAY
from typing_extensions import override

Expand Down Expand Up @@ -145,7 +145,7 @@ def test_pydantic_model() -> None: # noqa: D103


def test_pformat_many() -> None: # noqa: D103
result = mf_pformat_many("Example description:", obj_dict={"object_0": (1, 2, 3), "object_1": {4: 5}})
result = mf_pformat_dict("Example description:", obj_dict={"object_0": (1, 2, 3), "object_1": {4: 5}})

assert (
textwrap.dedent(
Expand All @@ -160,7 +160,7 @@ def test_pformat_many() -> None: # noqa: D103


def test_pformat_many_with_raw_strings() -> None: # noqa: D103
result = mf_pformat_many("Example description:", obj_dict={"object_0": "foo\nbar"}, preserve_raw_strings=True)
result = mf_pformat_dict("Example description:", obj_dict={"object_0": "foo\nbar"}, preserve_raw_strings=True)

assert (
textwrap.dedent(
Expand All @@ -176,7 +176,7 @@ def test_pformat_many_with_raw_strings() -> None: # noqa: D103


def test_pformat_many_with_strings() -> None: # noqa: D103
result = mf_pformat_many("Example description:", obj_dict={"object_0": "foo\nbar"})
result = mf_pformat_dict("Example description:", obj_dict={"object_0": "foo\nbar"})
assert (
textwrap.dedent(
"""\
Expand Down
6 changes: 3 additions & 3 deletions metricflow/data_table/mf_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import tabulate
from metricflow_semantics.mf_logging.formatting import indent
from metricflow_semantics.mf_logging.pretty_print import mf_pformat, mf_pformat_many
from metricflow_semantics.mf_logging.pretty_print import mf_pformat, mf_pformat_dict
from typing_extensions import Self

from metricflow.data_table.column_types import CellValue, InputCellValue, row_cell_types
Expand Down Expand Up @@ -47,7 +47,7 @@ def __post_init__(self) -> None: # noqa: D105
# Check that the type of the object in the rows match.
for column_index, cell_value in enumerate(row):
expected_cell_value_type = self.column_descriptions[column_index].column_type
assert cell_value is None or isinstance(cell_value, expected_cell_value_type), mf_pformat_many(
assert cell_value is None or isinstance(cell_value, expected_cell_value_type), mf_pformat_dict(
"Cell value type mismatch.",
{
"row_index": row_index,
Expand All @@ -59,7 +59,7 @@ def __post_init__(self) -> None: # noqa: D105
)
# Check that datetimes don't have a timezone set.
if isinstance(cell_value, datetime.datetime):
assert cell_value.tzinfo is None, mf_pformat_many(
assert cell_value.tzinfo is None, mf_pformat_dict(
"Time zone provided for datetime.",
{
"row_index": row_index,
Expand Down
10 changes: 5 additions & 5 deletions tests_metricflow/sql/compare_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dataclasses import dataclass
from typing import Dict, Optional, SupportsFloat

from metricflow_semantics.mf_logging.pretty_print import mf_pformat_many
from metricflow_semantics.mf_logging.pretty_print import mf_pformat_dict

from metricflow.data_table.column_types import CellValue
from metricflow.data_table.mf_table import MetricFlowDataTable
Expand Down Expand Up @@ -106,7 +106,7 @@ def check_data_tables_are_equal(

if expected_table.column_names != actual_table.column_names:
raise ValueError(
mf_pformat_many(
mf_pformat_dict(
"Column descriptions do not match.",
{
"expected_table_column_names": expected_table.column_names,
Expand All @@ -117,7 +117,7 @@ def check_data_tables_are_equal(

if expected_table.row_count != actual_table.row_count:
raise ValueError(
mf_pformat_many(
mf_pformat_dict(
"Row counts do not match.",
dict(
**{
Expand All @@ -132,7 +132,7 @@ def check_data_tables_are_equal(

if not allow_empty and expected_table.row_count == 0:
raise ValueError(
mf_pformat_many(
mf_pformat_dict(
f"Expected table is empty and {allow_empty=}. This may indicate an error in configuring the test.",
_generate_table_diff_fields(expected_table=expected_table, actual_table=actual_table),
preserve_raw_strings=True,
Expand All @@ -143,7 +143,7 @@ def check_data_tables_are_equal(

if mismatch is not None:
raise ValueError(
mf_pformat_many(
mf_pformat_dict(
mismatch.message,
dict(
**{
Expand Down

0 comments on commit ab53d7e

Please sign in to comment.