Skip to content

Commit

Permalink
Tweak logging in DataflowPlanBuilder.
Browse files Browse the repository at this point in the history
mf_pformat_many() makes the log look a little odd as it logs repr(str) instead
of str.
  • Loading branch information
plypaul committed Jan 19, 2024
1 parent 59d3458 commit d982b01
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
from metricflow.dataset.dataset import DataSet
from metricflow.errors.errors import UnableToSatisfyQueryError
from metricflow.filters.time_constraint import TimeRangeConstraint
from metricflow.mf_logging.pretty_print import mf_pformat, mf_pformat_many
from metricflow.mf_logging.formatting import indent
from metricflow.mf_logging.pretty_print import mf_pformat
from metricflow.mf_logging.runtime import log_runtime
from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow.plan_conversion.column_resolver import DunderColumnAssociationResolver
Expand Down Expand Up @@ -889,13 +890,9 @@ def _find_dataflow_recipe(
logger.info(f"Evaluation of {node} took {time.time() - start_time:.2f}s")

logger.info(
mf_pformat_many(
description="Evaluation for source node:",
obj_dict={
"node": node.text_structure(),
"evaluation": evaluation,
},
)
"Evaluation for source node:"
+ indent(f"\nnode:\n{indent(node.text_structure())}")
+ indent(f"\nevaluation:\n{indent(mf_pformat(evaluation))}")
)

if len(evaluation.unjoinable_linkable_specs) > 0:
Expand Down Expand Up @@ -926,14 +923,10 @@ def _find_dataflow_recipe(
evaluation = node_to_evaluation[node_with_lowest_cost_plan]

logger.info(
mf_pformat_many(
description="Lowest cost plan is:",
obj_dict={
"node": node_with_lowest_cost_plan.text_structure(),
"evaluation": evaluation,
"joins": len(node_to_evaluation[node_with_lowest_cost_plan].join_recipes),
},
)
"Lowest cost plan is:"
+ indent(f"\nnode:\n{indent(node_with_lowest_cost_plan.text_structure())}")
+ indent(f"\nevaluation:\n{indent(mf_pformat(evaluation))}")
+ indent(f"\njoins: {len(node_to_evaluation[node_with_lowest_cost_plan].join_recipes)}")
)

# Nodes containing the linkable instances will be joined to the source node, so these
Expand Down Expand Up @@ -1250,14 +1243,11 @@ def _build_aggregated_measure_from_measure_source_node(

if measure_recipe is None:
logger.info(
mf_pformat_many(
description="Looking for a recipe to get:",
obj_dict={
"measure_specs": [measure_spec],
"required_linkable_set": required_linkable_specs,
},
)
"Looking for a recipe to get:"
+ indent(f"\nmeasure_specs:\n{mf_pformat([measure_spec])}")
+ indent(f"\nevaluation:\n{mf_pformat(required_linkable_specs)}")
)

find_recipe_start_time = time.time()
measure_recipe = self._find_dataflow_recipe(
measure_spec_properties=measure_properties,
Expand All @@ -1271,7 +1261,7 @@ def _build_aggregated_measure_from_measure_source_node(
f"{time.time() - find_recipe_start_time:.2f}s"
)

logger.info(f"Using recipe:\n{mf_pformat(measure_recipe)}")
logger.info(f"Using recipe:\n{indent(mf_pformat(measure_recipe))}")

if measure_recipe is None:
# TODO: Improve for better user understandability.
Expand Down

0 comments on commit d982b01

Please sign in to comment.