Repository navigation
Conversation
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 4 tests: regression=4 unreleased=0 coverage=0 failing=0
TestAccept/bundle/python/numeric-variable-default/DMS=/PYDAB_VERSION=0.266.0: branch ✅ | main (396e51a) ❌ | latest (v1.27.0) ❌main (396e51a): latest (v1.27.0): same output as main (396e51a) TestAccept/bundle/python/numeric-variable-default/DMS=/PYDAB_VERSION=current: branch ✅ | main (396e51a) ❌ | latest (v1.27.0) ❌main (396e51a): latest (v1.27.0): TestAccept/bundle/python/numeric-variable-default/DMS=true/PYDAB_VERSION=0.266.0: branch ✅ | main (396e51a) ❌ | latest (v1.27.0) ❌main (396e51a): latest (v1.27.0): same output as main (396e51a) TestAccept/bundle/python/numeric-variable-default/DMS=true/PYDAB_VERSION=current: branch ✅ | main (396e51a) ❌ | latest (v1.27.0) ❌main (396e51a): latest (v1.27.0): |
✅ Integration test reportCommit: 4f62523
Top 9 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at c942a1f. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR fixes the Python mutator rejecting whole-number floats (like 1.0) that come back from Python as ints, by adding an isWholeFloatAsInt guard in VisitUpdate. The approach is reasonable and the tests cover the main cases. Two issues remain: the changelog entry will fail CI because it lacks the required trailing PR link, and the float/int comparison can silently drop a genuine change for large values beyond 2^53 due to float64 precision loss—a pattern the codebase already guards against elsewhere.
| @@ -0,0 +1 @@ | |||
| * Fix `bundle` commands failing with "unexpected change at variables.X.default" when a bundle with Python code has a variable default such as `1.0`, `1e3` or `0012345678901234`. | |||
There was a problem hiding this comment.
[blocking] .nextchanges/README.md requires a trailing PR link on every entry and CI enforces it. Append ([#7842](https://github.com/databricks/cli/pull/7842)) after the period.
There was a problem hiding this comment.
Right, the link was only in the working tree when I committed. Fixed in 4f62523.
| // back from Python as an int. | ||
| func isWholeFloatAsInt(left, right dyn.Value) bool { | ||
| return left.Kind() == dyn.KindFloat && right.Kind() == dyn.KindInt && | ||
| left.MustFloat() == float64(right.MustInt()) |
There was a problem hiding this comment.
[nice to have] float64(right.MustInt()) is lossy for any int64 whose absolute value exceeds 2^53: e.g. float64(9007199254740993) rounds to 9007199254740992.0, so if the original float is 9007199254740992.0 the comparison returns true and the real update is silently dropped. normalizeFloat in libs/dyn/convert/normalize.go:441 already guards against exactly this with a round-trip check. Adding && right.MustInt() == int64(left.MustFloat()) here would close the gap.
There was a problem hiding this comment.
Good catch, but int64(f) == i alone would reject the shortest-decimal case below. 4f62523 accepts an int only if it equals the float exactly or is exactly the text json.Marshal wrote for it (strconv.FormatFloat(f, 'f', -1, 64)). So 9007199254740992.0 → 9007199254740993 is reported as a change (TestMergeOutput_disallowNearbyIntAbove2p53).
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Fable 5.2, cross-verified). Only points the reviewers agreed on are posted.
| // back from Python as an int. | ||
| func isWholeFloatAsInt(left, right dyn.Value) bool { | ||
| return left.Kind() == dyn.KindFloat && right.Kind() == dyn.KindInt && | ||
| left.MustFloat() == float64(right.MustInt()) |
There was a problem hiding this comment.
[AI Generated] Above 2^53 Python returns the float's shortest decimal, not its exact value: 1234567890123456789.0 comes back as 1234567890123456800. This check accepts it, but an exact round-trip would not. Can a test pin that case?
There was a problem hiding this comment.
Pinned in 4f62523: TestMergeOutput_wholeFloatAsInt_shortestDecimalAbove2p53, and an above_2_53 target in the acceptance test (1234567890123456789.0) that goes through real Python. It fails on main and passes here.
| } | ||
|
|
||
| // isWholeFloatAsInt reports whether right is the int Python returns for the float left. | ||
| // JSON doesn't tell 1.0 from 1, so a float such as a variable default of 1.0 comes |
There was a problem hiding this comment.
[AI Generated] nit: It's json.Marshal in writeInputFile (python_mutator.go:506) that writes 1.0 as 1; Python's json keeps 1.0 a float. Could the comment name that cause instead of JSON itself?
There was a problem hiding this comment.
Done in 4f62523, the comment now names json.Marshal in writeInputFile.
| VisitUpdate: func(valuePath dyn.Path, _, right dyn.Value) (dyn.Value, error) { | ||
| VisitUpdate: func(valuePath dyn.Path, left, right dyn.Value) (dyn.Value, error) { | ||
| if isWholeFloatAsInt(left, right) { | ||
| return left, nil |
There was a problem hiding this comment.
[AI Generated] nit: applyPythonOutput's doc comment lists where the result differs from Python's output (kept locations, undone empty deletes). Keeping the original float when Python returns a whole int is a third case; add a bullet there?
JSON doesn't tell 1.0 from 1, so a float variable default comes back from Python as an int. Treat an int equal to the original float as unchanged and keep the original value. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Accept an int from Python only when it equals the float exactly or is the shortest decimal json.Marshal wrote for it, so a real change above 2^53 is still reported. Name json.Marshal as the cause, document the preserved float in applyPythonOutput, and add the missing PR link to the changelog. Co-authored-by: Isaac <no-reply@databricks.com>
c942a1f to
4f62523
Compare
Changes
When merging Python mutator output, an int equal to the original float is treated as unchanged and the original value is kept.
Why
JSON doesn't tell
1.0from1, so a float variable default came back from Python as an int and failed the bundle withunexpected change at "variables.id.default" (update). See #7841.Not fixed: a whole float beyond int64 (e.g.
0012345678901234567890) still fails, because Python returns an int our YAML loader can't parse. That needs a loader change and is left as is.Tests
Updated golden from #7841; unit tests in
apply_python_output_test.go.This pull request and its description were written by Isaac.