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] wc.workspace_conf.get_status("enableDeprecatedClusterNamedInitScripts") is failing with type object 'dict' has no attribute 'from_dict' #458

Closed
alexott opened this issue Nov 27, 2023 · 2 comments

Comments

@alexott
Copy link
Contributor

alexott commented Nov 27, 2023

Description

workspace_conf.get_status fails with error

Reproduction

In a notebook, with DBR 14.0 ML run

wc = WorkspaceClient()
wc.workspace_conf.get_status("enableDeprecatedClusterNamedInitScripts")

it fails with following error:

ttributeError: type object 'dict' has no attribute 'from_dict'
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File <command-85549842133900>, line 1
----> 1 wc.workspace_conf.get_status(keys="enableDeprecatedClusterNamedInitScripts")

File /local_disk0/.ephemeral_nfs/envs/pythonEnv-31d522b2-5781-46e3-8fbb-a8f7361afd1d/lib/python3.10/site-packages/databricks/sdk/service/settings.py:1691, in WorkspaceConfAPI.get_status(self, keys)
   1689 headers = {'Accept': 'application/json', }
   1690 res = self._api.do('GET', '/api/2.0/workspace-conf', query=query, headers=headers)
-> 1691 return WorkspaceConf.from_dict(res)

File /usr/lib/python3.10/typing.py:983, in _BaseGenericAlias.__getattr__(self, attr)
    980 # We are careful for copy and pickle.
    981 # Also for simplicity we don't relay any dunder names
    982 if '__origin__' in self.__dict__ and not _is_dunder(attr):
--> 983     return getattr(self.__origin__, attr)
    984 raise AttributeError(attr)

Expected behavior
A clear and concise description of what you expected to happen.

Is it a regression?
Did this work in a previous version of the SDK? If so, which versions did you try?

Debug Logs
The SDK logs helpful debugging information when debug logging is enabled. Set the log level to debug by adding logging.basicConfig(level=logging.DEBUG) to your program, and include the logs here.

I see that REST API call is done correctly:

EBUG:urllib3.connectionpool:https://oregon.cloud.databricks.com:443 "GET /api/2.0/workspace-conf?keys=enableDeprecatedClusterNamedInitScripts HTTP/1.1" 200 None
DEBUG:databricks.sdk:GET /api/2.0/workspace-conf?keys=enableDeprecatedClusterNamedInitScripts
< 200 OK
< {
<   "enableDeprecatedClusterNamedInitScripts": null
< }

Other Information

  • OS: [e.g. macOS]
  • Version: [e.g. 0.1.0]

Additional context
Add any other context about the problem here.

@jurw2201
Copy link

This is related to issue #128. If we look at the source code, WorkspaceConf has only been defined as a 'Dict[str, str]'. It needs be blown-up as a class.

@mgyucht
Copy link
Contributor

mgyucht commented Dec 4, 2023

Thanks for this @alexott. This duplicates #128, so I'll close this issue out for now. You can follow that one for tracking/to provide further feedback.

@mgyucht mgyucht closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
github-merge-queue bot pushed a commit that referenced this issue Feb 1, 2024
## Changes
WorkspaceConf's APIs are unique in Databricks as they are the only
methods that accept a map for the request body (all other methods with
request bodies require a struct). This is incompatible with the Python
SDK, which generally has all fields of the request as method parameters.

This PR changes the behavior of methods that get and return maps. On the
set pathway, autogenerated code will include a field `contents` with a
map type corresponding to the type of the request body. This parameter
will be passed directly into the `do()` method of `ApiClient`. On the
get pathway, we'll return the deserialized response directly (which is
already a dictionary), rather than calling an imaginary
`WorkspaceConf.from_dict()` method.

Closes #500 and #128. Relates to #458, #455, #345, #211, and #167.

## Tests
New integration test for workspace conf passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants