Skip to content

Python for DABs spot_bid_max_price azure attribute error #2875

@hanson-ma-8451

Description

@hanson-ma-8451

Describe the issue

When defining jobs solely with yaml format (but not both), defining spot_bid_max_price (e.g. -1) for azure_attributes in a new_cluster job_clusters definition works just fine. However, when defining those same jobs, but one in python and another in yaml, with different unique identifiers/names), I am running into a "ValueError: Unexpected type: <class 'float'> for -1" error after a databricks bundle validate. I verified that it seems like the spot_bid_max_price attribute is the problem since once I got rid of the spot_bid_max_price definition from both jobs, the validate command passes. Thus, a job that was validating correctly with spot_bid_max_price in yaml no longer passes once python for DABs is incorporated.

Additionally, after some more testing I found that having only jobs defined in Python (none in yaml) with spot_bid_max_price defined also runs into issues (with any value, not just -1).

Configuration

Please provide a minimal reproducible configuration for the issue
Using databricks-bundles version 0.251.0, Databricks CLI v0.251.0. Using my own defined job, but also tested in the jobs_as_code_project example repo listed here: https://docs.databricks.com/aws/en/dev-tools/bundles/python/#create-a-project-from-the-template and reproduced the same error
Note: this issue is not only with the value of -1 for spot_bid_max_price. It happens with any integer provided (and if passed in as a string instead)

Steps to reproduce the behavior

Please list the steps required to reproduce the issue, for example:

  1. Follow the steps provided here: https://docs.databricks.com/aws/en/dev-tools/bundles/python/#create-a-project-from-the-template to create the repo and get its dependencies
  2. Edit the "job_clusters" section of jobs_as_code_project_job.py to have an ""azure_attributes": {"spot_bid_max_price": -1, }" dict added to the "new_cluster" dict
  3. Run "databricks bundle validate"

Expected Behavior

Validation should be OK!

Actual Behavior

Received an error saying "Error: Error while loading 'resources.jobs_as_code_project_job'" and "ValueError: Unexpected type: <class 'float'> for -1" error

OS and CLI version

MacOS Sequoia 15.4, CLI v0.251.0

Is this a regression?

Did this work in a previous version of the CLI? If so, which versions did you try? Not sure

Debug Logs

Output logs if you run the command with debug logs enabled. Example: databricks bundle deploy --log-level=debug. Redact if needed

15:17:15 Debug: python mutator process failed: .venv/bin/python3 -m databricks.bundles.build --phase load_resources --input /var/folders/0z//T/-python244705955/input.json --output /var/folders/0z//T/-python244705955/output.json --diagnostics /var/folders/0z//T/-python244705955/diagnostics.json --locations /var/folders/0z//T/-python244705955/locations.json: exit status 1 pid=25320 mutator=PythonMutator(load_resources) sdk=true
15:17:15 Debug: Error: Traceback (most recent call last):
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_load.py", line 76, in load_resources_from_package_module
modules.append(importlib.import_module(module_name))
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/init.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 1026, in exec_module
File "", line 488, in _call_with_frames_removed
File "/Users/
/Desktop/hello/jobs_as_code_project/resources/jobs_as_code_project_job.py", line 8, in
jobs_as_code_project_job = Job.from_dict(
{
...<60 lines>...
}
)
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/jobs/_models/job.py", line 178, in from_dict
return _transform(cls, value)
File "/Users/
/Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 180, in _transform
field.name: _transform_field(cls, field, value[field.name])
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 135, in _transform_field
return _transform(field.type, value)
File "/Users/
/Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 164, in _transform
return _transform(union_arg, value)
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 194, in _transform
return [_transform(arg, item) for item in value] # type:ignore
~~~~~~~~~~^^^^^^^^^^^
File "/Users/
/Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 164, in _transform
return _transform(union_arg, value)
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 180, in _transform
field.name: _transform_field(cls, field, value[field.name])
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/
/Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 135, in _transform_field
return _transform(field.type, value)
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 164, in _transform
return _transform(union_arg, value)
File "/Users/
/Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 180, in _transform
field.name: _transform_field(cls, field, value[field.name])
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 135, in _transform_field
return _transform(field.type, value)
File "/Users/
/Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 164, in _transform
return _transform(union_arg, value)
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 180, in _transform
field.name: _transform_field(cls, field, value[field.name])
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/
/Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 135, in _transform_field
return _transform(field.type, value)
File "/Users//Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 164, in _transform
return _transform(union_arg, value)
File "/Users/
/Desktop/hello/jobs_as_code_project/.venv/lib/python3.13/site-packages/databricks/bundles/core/_transform.py", line 228, in _transform
raise ValueError(f"Unexpected type: {cls} for {value}")
ValueError: Unexpected type: <class 'float'> for -1
pid=25320 mutator=PythonMutator(load_resources)
Error: Error while loading 'resources.jobs_as_code_project_job'

Metadata

Metadata

Assignees

Labels

DABsDABs related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions