Skip to content
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

[ISSUE] JobsAPI.create in v0.4.0 does not serialize the access_control_list correctly #270

Closed
pspeter opened this issue Aug 7, 2023 · 4 comments · May be fixed by #264
Closed

[ISSUE] JobsAPI.create in v0.4.0 does not serialize the access_control_list correctly #270

pspeter opened this issue Aug 7, 2023 · 4 comments · May be fixed by #264

Comments

@pspeter
Copy link

pspeter commented Aug 7, 2023

Description
The JobsAPI.create() method does not transform access_control_list into a list of dicts, so the request fails when trying to serialize it to JSON.

Reproduction

w = WorkspaceClient()
w.jobs.create(access_control_list=[AccessControlRequest()])

Stacktrace:

  [...]
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/databricks/sdk/service/jobs.py", line 2888, in create
    json = self._api.do('POST', '/api/2.1/jobs/create', body=body)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/databricks/sdk/core.py", line 949, in do
    response = self._session.request(method,
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/requests/models.py", line 371, in prepare
    self.prepare_body(data, files, json)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/requests/models.py", line 511, in prepare_body
    body = complexjson.dumps(json, allow_nan=False)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type AccessControlRequest is not JSON serializable

Other Information

  • Version: 0.4.0
@nfx
Copy link
Contributor

nfx commented Aug 7, 2023

it should be fixed #264

@mgyucht
Copy link
Contributor

mgyucht commented Aug 10, 2023

This is not fixed by #264. The issue is that we must call .as_dict in jobs.create().

EDIT: Nevermind, it would be fixed, but we need to revisit the approach taken in that PR.

@jiropardo
Copy link

hi @nfx , @mgyucht , will this also be fixed in v0.6.0 ?

@mgyucht
Copy link
Contributor

mgyucht commented Oct 5, 2023

This was fixed in #382. It should be released in next week's release.

@mgyucht mgyucht closed this as completed Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants