Skip to content

[BUG] JobTaskSettings as_dict and from_dict Library error #167

@aseufert

Description

@aseufert

Not sure if I'm doing something wrong here but I'm getting an AttributeError: 'dict' object has no attribute 'as_dict' error when I use databricks.sdk.service.jobs.CreateJob.from_dict() or databricks.sdk.service.jobs.JobSettings.as_dict(). It appears that the libraries remain a list of dictionaries but are expected to be a list of the Library class, hence the 'dict' object has no attribute 'as_dict'.

The error is cause by line 739.

Here's an example of what I'm doing:

from databricks.sdk import WorkspaceClient
from databricks.sdk.service import jobs

w = WorkspaceClient()

job_dict = {} #job dictionary created from valid JSON object in UI

job_create = jobs.CreateJob.from_dict(job_dict)
w.jobs.create(request=job_create)

Here's the full error:


AttributeError Traceback (most recent call last)
File :1
----> 1 w.jobs.create(request=job_create)

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.9/site-packages/databricks/sdk/service/jobs.py:2235, in JobsAPI.create(self, access_control_list, continuous, email_notifications, format, git_source, job_clusters, max_concurrent_runs, name, notification_settings, run_as, schedule, tags, tasks, timeout_seconds, trigger, webhook_notifications, **kwargs)
2218 if not request: # request is not given through keyed args
2219 request = CreateJob(access_control_list=access_control_list,
2220 continuous=continuous,
2221 email_notifications=email_notifications,
(...)
2233 trigger=trigger,
2234 webhook_notifications=webhook_notifications)
-> 2235 body = request.as_dict()
2237 json = self._api.do('POST', '/api/2.1/jobs/create', body=body)
2238 return CreateResponse.from_dict(json)

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.9/site-packages/databricks/sdk/service/jobs.py:251, in CreateJob.as_dict(self)
249 if self.schedule: body['schedule'] = self.schedule.as_dict()
250 if self.tags: body['tags'] = self.tags
--> 251 if self.tasks: body['tasks'] = [v.as_dict() for v in self.tasks]
252 if self.timeout_seconds is not None: body['timeout_seconds'] = self.timeout_seconds
253 if self.trigger: body['trigger'] = self.trigger.as_dict()

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.9/site-packages/databricks/sdk/service/jobs.py:251, in (.0)
249 if self.schedule: body['schedule'] = self.schedule.as_dict()
250 if self.tags: body['tags'] = self.tags
--> 251 if self.tasks: body['tasks'] = [v.as_dict() for v in self.tasks]
252 if self.timeout_seconds is not None: body['timeout_seconds'] = self.timeout_seconds
253 if self.trigger: body['trigger'] = self.trigger.as_dict()

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.9/site-packages/databricks/sdk/service/jobs.py:739, in JobTaskSettings.as_dict(self)
737 if self.existing_cluster_id is not None: body['existing_cluster_id'] = self.existing_cluster_id
738 if self.job_cluster_key is not None: body['job_cluster_key'] = self.job_cluster_key
--> 739 if self.libraries: body['libraries'] = [v.as_dict() for v in self.libraries]
740 if self.max_retries is not None: body['max_retries'] = self.max_retries
741 if self.min_retry_interval_millis is not None:

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.9/site-packages/databricks/sdk/service/jobs.py:739, in (.0)
737 if self.existing_cluster_id is not None: body['existing_cluster_id'] = self.existing_cluster_id
738 if self.job_cluster_key is not None: body['job_cluster_key'] = self.job_cluster_key
--> 739 if self.libraries: body['libraries'] = [v.as_dict() for v in self.libraries]
740 if self.max_retries is not None: body['max_retries'] = self.max_retries
741 if self.min_retry_interval_millis is not None:

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenissues related to generated code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions