Repository navigation
fix(api): advertise only the time grains Prophet can resolve - #43710
Conversation
Code Review Agent Run #a77d73Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #43710 +/- ##
=======================================
Coverage 79.90% 79.90%
=======================================
Files 2916 2916
Lines 170738 170742 +4
Branches 39556 39557 +1
=======================================
+ Hits 136435 136439 +4
Misses 31785 31785
Partials 2518 2518
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks @SEPURI-SAI-KRISHNA, a Prophet-only choices source instead of narrowing the shared helper is the right shape, and picking up |
29939f4 to
b9c3dd2
Compare
|
Rebased on master, thanks @rusackas. The conflict was where you said, the tail of One extra file beyond the rebase. "PT30M",
+ "PT0.5H",
"PT1H",
...
"P3M",
+ "P0.25Y",
"P1Y",Nothing else in the spec moves, and the change is scoped to Verified locally: the 46 tests in CI is green on the rebase, |
Code Review Agent Run #df466bActionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
b9c3dd2 to
44cc584
Compare
Code Review Agent Run #d8900aActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
rusackas
left a comment
There was a problem hiding this comment.
Thanks for the rebase @SEPURI-SAI-KRISHNA, and the openapi diff writeup is appreciated. LGTM, approving!
44cc584 to
b97a603
Compare
… to a custom validator Unrelated to the Prophet grain narrowing in this branch: the time_grain_sqla field's validator was swapped for a plain function elsewhere, which apispec can no longer introspect into an enum, so the published spec had drifted since. Regenerated per check-openapi-spec-drift's own instructions.
|
Rebased on master (conflict was just where #43585 landed nearby in |
|
Thanks for the rebase and for catching the second drift, the Worth restating what this PR still does, because #43585 landed the same core narrowing Already fixed by #43585. The Prophet field validating against Still outstanding before this PR. #43585 changed the validator but did not
The two missing from the published spec are Test coverage. Three tests, none of which have an equivalent in master:
So: a spec resync, a regression guard against the drift that just happened, and an |
|
Bito Automatic Review Skipped – PR Already Merged |
SUMMARY
Fixes #43356.
ChartDataProphetOptionsSchema.time_grainvalidates againstget_time_grain_choices(), which mergesbuiltin_time_grainswith theoperator-configured
TIME_GRAIN_ADDONS.prophet()then resolves the grainthrough
PROPHET_TIME_GRAIN_MAP, a static map that cannot contain anoperator's arbitrary addon key. So a configured custom grain passes schema
validation and then fails at the lookup, the API advertises a forecast it
cannot serve.
Reproducing on
masterwithTIME_GRAIN_ADDONS = {"PT7M": "7 minute"}:The addon keys are arbitrary ISO-8601 durations, so the static map cannot
simply be extended to cover them, and converting them to pandas frequencies at
runtime is not total,
P0.25Ybeing the obvious case. That leaves the otheroption the issue identifies: publish only what the operation can resolve.
This adds
get_prophet_time_grain_choices(), returning the keys ofPROPHET_TIME_GRAIN_MAP, and points the Prophet field's validator at it.get_time_grain_choices()is deliberately left alone, it is shared withtime_grain_sqlaonChartDataExtrasSchema, where addon grains arelegitimately supported, and narrowing it there would be a regression.
This widens the published set as well as narrowing it.
PT0.5H(
HALF_HOUR) andP0.25Y(QUARTER_YEAR) are in the map but not inbuiltin_time_grains, so they were previously rejected by the schema despiteresolving fine in
prophet(). They are now accepted. Net effect on a defaultdeployment is 19 advertised grains -> 21, with every one of them resolvable.
No working request changes behaviour: the grains this removes from the spec
never produced a forecast.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A, backend-only fix.
TESTING INSTRUCTIONS
Three tests are added:
test_prophet_schema_advertises_only_resolvable_grainsasserts the field'sown
OneOfchoices equal the map's keys. It reads the validator rather thanthe helper, so re-pointing the field back at
get_time_grain_choices()failshere rather than silently reintroducing the bug.
test_prophet_rejects_addon_grain_accepted_by_time_grain_sqlaconfiguresTIME_GRAIN_ADDONS = {"PT7M": "7 minute"}and asserts the addon is stilladvertised by the shared helper while the Prophet schema rejects it. This is
the reported bug, and it pins the "do not narrow the shared helper"
constraint.
test_prophet_accepts_every_mapped_graincovers the five grains that nowload and resolve, including the two newly advertised aliases.
The three pre-existing
time_grainassertions are unchanged and still pass —P1Dremains valid andinvalid_grainremains rejected.ADDITIONAL INFORMATION
Note for reviewers: #43206 also edits
ChartDataProphetOptionsSchema, aboutfifty lines below this change (
monthly_seasonality->daily_seasonality,plus
index). Separate hunks, so the two should merge cleanly, but whicheverlands second may want a rebase.