Repository navigation
acc: python mutator fails on whole-number float variable defaults #7841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| bundle: | ||
| name: my_project | ||
|
|
||
| sync: {paths: []} # don't need to copy files | ||
|
|
||
| python: | ||
| resources: | ||
| - "resources:load_resources" | ||
|
|
||
| variables: | ||
| id: | ||
| default: 42 | ||
|
|
||
| # Each target sets a different default for var.id. | ||
| targets: | ||
| int: | ||
| default: true | ||
| # YAML reads a leading-zero value containing 8 or 9 as a float. | ||
| leading_zero: | ||
| variables: | ||
| id: 0012345678901234 | ||
| float_whole: | ||
| variables: | ||
| id: 1.0 | ||
| exponent: | ||
| variables: | ||
| id: 1e3 | ||
| float_fraction: | ||
| variables: | ||
| id: 3.10 | ||
| # Beyond 2^53 the CLI sends the float's shortest decimal, which Python reads | ||
| # as an int that is not exactly equal to the float. | ||
| above_2_53: | ||
| variables: | ||
| id: 1234567890123456789.0 | ||
| complex: | ||
| variables: | ||
| id: | ||
| nested: 1.0 | ||
| # A whole float beyond int64 comes back from Python as an int we can't parse. | ||
| huge: | ||
| variables: | ||
| id: 0012345678901234567890 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Cloud = false | ||
| EnvMatrix.DMS = ["", "true"] | ||
| EnvMatrix.PYDAB_VERSION = ["0.266.0", "current"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
|
|
||
| === int | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate -t int --output json | ||
| {"default":42,"value":42} | ||
|
|
||
| === leading_zero | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate -t leading_zero --output json | ||
| Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default" (update) | ||
|
|
||
| {"default":12345678901234,"value":12345678901234} | ||
|
|
||
| === float_whole | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate -t float_whole --output json | ||
| Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default" (update) | ||
|
|
||
| {"default":1,"value":1} | ||
|
|
||
| === exponent | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate -t exponent --output json | ||
| Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default" (update) | ||
|
|
||
| {"default":1000,"value":1000} | ||
|
|
||
| === float_fraction | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate -t float_fraction --output json | ||
| {"default":3.1,"value":3.1} | ||
|
|
||
| === above_2_53 | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate -t above_2_53 --output json | ||
| Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default" (update) | ||
|
|
||
| {"default":1234567890123456800,"value":1234567890123456800} | ||
|
|
||
| === complex | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate -t complex --output json | ||
| Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default.nested" (update) | ||
|
|
||
| {"default":{"nested":1},"value":{"nested":1}} | ||
|
|
||
| === huge | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate -t huge --output json | ||
| Error: failed to parse output file: yaml ([TEST_TMP_DIR]/__generated_by_python__.yml:[POS]): invalid int value: 12345678901234567000 | ||
|
|
||
| {"default":12345678901234567000,"value":12345678901234567000} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from databricks.bundles.core import Bundle, Resources | ||
|
|
||
|
|
||
| def load_resources(bundle: Bundle) -> Resources: | ||
| return Resources() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| for target in int leading_zero float_whole exponent float_fraction above_2_53 complex huge; do | ||
| title "$target" | ||
| # Only these targets pass validation today; the rest must fail. | ||
| case $target in | ||
| int|float_fraction) trace uv run $UV_ARGS -q $CLI bundle validate -t $target --output json > tmp.json ;; | ||
| *) musterr trace uv run $UV_ARGS -q $CLI bundle validate -t $target --output json > tmp.json ;; | ||
| esac | ||
| jq -c .variables.id tmp.json | ||
| done |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Badness = 'Whole-number float variable defaults fail with an internal error when the bundle has Python code. A whole float beyond int64 fails differently: the Python output cannot be parsed.' | ||
| Ignore = [".databricks", "__pycache__", "tmp.json"] | ||
|
|
||
| # The position depends on the size of the Python output, which includes paths. | ||
| # The separator before the file name is a backslash on Windows. | ||
| [[Repls]] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [AI Generated] Major: On Windows
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 4a2be77. I kept it to the one path ( |
||
| Old = '[\\/]__generated_by_python__\.yml:\d+:\d+' | ||
| New = '/__generated_by_python__.yml:[POS]' | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nice to have] The script removes
.databricks,__pycache__, andtmp.jsonwithrm -fr(script line 7) instead of declaring them inIgnore. The testing rules requireIgnorefor test artifacts. AddIgnore = [".databricks", "__pycache__", "tmp.json"]here and drop therm -frline fromscript.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 4a2be77:
.databricks,__pycache__andtmp.jsonare inIgnoreand therm -frline is gone.