feat(features): implement promotion compute method (#109)#112
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Sorry @w7-mgfcode, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Summary
Lands PRP-3.1D — the promotion compute slice for time-safe featuresets. Rebased onto
devafter PR #111 (lifecycle) landed.FeatureEngineeringService._compute_promotion_features(df, promotion_rows_df).compute_features, gated onself.config.promotion_config.getattr(self, "_promotion_rows_df", None)— no new public API. Empty-DataFrame fallback when unset (matches the additive-contract invariant).promo_{kind}_active_lag{N}(Int64 nullable) +promo_{kind}_intensity_lag{N}(float64).store_id IS NULL) handled via two-pass match — never via NaN-key merge.max(discount_pct)for intensity;activestays 0/1.Time-safety
groupby(entity_cols).shift(lag_days)is the leakage gate — same-day promo MUST NOT appear inactive_lag{N}at day D.TestPromotionLeakage(4 cases) asserts this invariant: day-of-start = 0, day-after = 1, and chain-wide does not bleed across products.test_leakage.pyremains the canonical spec; no existing invariants weakened.Scope
service.py,tests/test_leakage.py,tests/test_service.py(3 files, +544/-0 vsdev).schemas.py/routes.py/conftest.py/ migration / docs edits.config_hash_unchanged_when_phase2_omitted) still passes.promotionrows from the DB) lands in PRP-3.1E.Rebase notes
09c9bc6→037b62fon top of newdev(which contains B's lifecycle additions).compute_features+ the method-list slot just beforeclass FeatureDataLoader:+ identical class-list slots in the two test files.dev, appended D's promotion additions next to them (step-7 wiring + new method + new test classes at the end of the existing class chain). One intentional non-pickup: did not propagate D's silent deletion ofassert result.feature_columns == ["lag_1"]inTestComputeFeatures::test_empty_dataframe_handling— that looked like an unintended edit artifact.Test plan
ruff check+ruff format --checkcleanpytest -vonapp/features/featuresets/— 95 tests pass (4 new leakage + 9 new service cases on top of the existing slice)Refs
Part of #109 (Phase 2 feature wiring). PRP-3.1E will land the loader extension that populates
_promotion_rows_dffrom the DB join.