Skip to content

Commit 341f43b

Browse files
CLI predict: drop dead serializer imports, document intentional JSON divergence (#27)
The three serializers explanation_to_dict, interval_to_dicts, whatif_to_dict were imported from model_utils under underscore aliases but immediately shadowed by local defs of the same name, making the imports dead code. Remove the dead aliases (keeping coerce_features, extract_feature_info, inner_pipeline, which are used) and replace them with a comment documenting that the CLI's lean, versioned --json serializers are intentionally separate from the richer MCP copies in model_utils. Co-authored-by: Ahmed K. Hafsi <25119333+ahmed-hafsi@users.noreply.github.com>
1 parent 937e726 commit 341f43b

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎src/p2predict/cli/predict.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
from p2predict.explain import Explanation, explain_batch, explain_row, top_drivers
1616
from p2predict.intervals import coverage_health, predict_interval
1717
from p2predict.json_output import JSON_SCHEMA_VERSION, emit, emit_error
18+
# NOTE: the JSON serializers (_interval_per_row, _explanation_to_dict,
19+
# _whatif_to_dict) are defined LOCALLY below, on purpose. They are NOT imported
20+
# from model_utils. The CLI ``--json`` schema is versioned (JSON_SCHEMA_VERSION)
21+
# and locked by tests/test_json_output.py, so it stays deliberately lean. The
22+
# model_utils copies serve the MCP surface and carry extra business-facing
23+
# fields (price_drivers, starting_point, interval reliability/say_to_user,
24+
# what_if summary) that the locked CLI schema intentionally omits. Keep these
25+
# two surfaces independent. Only the pipeline helpers below are shared.
1826
from p2predict.model_utils import (
1927
coerce_features as _coerce_features,
20-
explanation_to_dict as _explanation_to_dict,
2128
extract_feature_info as _extract_feature_info,
2229
inner_pipeline as _inner_pipeline,
23-
interval_to_dicts as _interval_per_row,
24-
whatif_to_dict as _whatif_to_dict,
2530
)
2631
from p2predict.trained_model_io import LoadModel
2732
from p2predict.whatif import (

0 commit comments

Comments
 (0)