-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathtask.py
More file actions
492 lines (408 loc) · 18 KB
/
Copy pathtask.py
File metadata and controls
492 lines (408 loc) · 18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, TypedDict
from databricks.bundles.core._transform import _transform
from databricks.bundles.core._transform_to_json import _transform_to_json_value
from databricks.bundles.core._variable import (
VariableOr,
VariableOrList,
VariableOrOptional,
)
from databricks.bundles.jobs._models.clean_rooms_notebook_task import (
CleanRoomsNotebookTask,
CleanRoomsNotebookTaskParam,
)
from databricks.bundles.jobs._models.cluster_spec import ClusterSpec, ClusterSpecParam
from databricks.bundles.jobs._models.condition_task import (
ConditionTask,
ConditionTaskParam,
)
from databricks.bundles.jobs._models.dashboard_task import (
DashboardTask,
DashboardTaskParam,
)
from databricks.bundles.jobs._models.dbt_platform_task import (
DbtPlatformTask,
DbtPlatformTaskParam,
)
from databricks.bundles.jobs._models.dbt_task import DbtTask, DbtTaskParam
from databricks.bundles.jobs._models.for_each_task import (
ForEachTask,
ForEachTaskParam,
)
from databricks.bundles.jobs._models.gen_ai_compute_task import (
GenAiComputeTask,
GenAiComputeTaskParam,
)
from databricks.bundles.jobs._models.jobs_health_rules import (
JobsHealthRules,
JobsHealthRulesParam,
)
from databricks.bundles.jobs._models.library import Library, LibraryParam
from databricks.bundles.jobs._models.notebook_task import (
NotebookTask,
NotebookTaskParam,
)
from databricks.bundles.jobs._models.pipeline_task import (
PipelineTask,
PipelineTaskParam,
)
from databricks.bundles.jobs._models.power_bi_task import PowerBiTask, PowerBiTaskParam
from databricks.bundles.jobs._models.python_wheel_task import (
PythonWheelTask,
PythonWheelTaskParam,
)
from databricks.bundles.jobs._models.run_if import RunIf, RunIfParam
from databricks.bundles.jobs._models.run_job_task import (
RunJobTask,
RunJobTaskParam,
)
from databricks.bundles.jobs._models.spark_jar_task import (
SparkJarTask,
SparkJarTaskParam,
)
from databricks.bundles.jobs._models.spark_python_task import (
SparkPythonTask,
SparkPythonTaskParam,
)
from databricks.bundles.jobs._models.spark_submit_task import (
SparkSubmitTask,
SparkSubmitTaskParam,
)
from databricks.bundles.jobs._models.sql_task import SqlTask, SqlTaskParam
from databricks.bundles.jobs._models.task_dependency import (
TaskDependency,
TaskDependencyParam,
)
from databricks.bundles.jobs._models.task_email_notifications import (
TaskEmailNotifications,
TaskEmailNotificationsParam,
)
from databricks.bundles.jobs._models.task_notification_settings import (
TaskNotificationSettings,
TaskNotificationSettingsParam,
)
from databricks.bundles.jobs._models.webhook_notifications import (
WebhookNotifications,
WebhookNotificationsParam,
)
if TYPE_CHECKING:
from typing_extensions import Self
@dataclass(kw_only=True)
class Task:
""""""
task_key: VariableOr[str]
"""
A unique name for the task. This field is used to refer to this task from other tasks.
This field is required and must be unique within its parent job.
On Update or Reset, this field is used to reference the tasks to be updated or reset.
"""
clean_rooms_notebook_task: VariableOrOptional[CleanRoomsNotebookTask] = None
"""
The task runs a [clean rooms](https://docs.databricks.com/clean-rooms/index.html) notebook
when the `clean_rooms_notebook_task` field is present.
"""
condition_task: VariableOrOptional[ConditionTask] = None
"""
The task evaluates a condition that can be used to control the execution of other tasks when the `condition_task` field is present.
The condition task does not require a cluster to execute and does not support retries or notifications.
"""
dashboard_task: VariableOrOptional[DashboardTask] = None
"""
The task refreshes a dashboard and sends a snapshot to subscribers.
"""
dbt_platform_task: VariableOrOptional[DbtPlatformTask] = None
"""
:meta private: [EXPERIMENTAL]
"""
dbt_task: VariableOrOptional[DbtTask] = None
"""
The task runs one or more dbt commands when the `dbt_task` field is present. The dbt task requires both Databricks SQL and the ability to use a serverless or a pro SQL warehouse.
"""
depends_on: VariableOrList[TaskDependency] = field(default_factory=list)
"""
An optional array of objects specifying the dependency graph of the task. All tasks specified in this field must complete before executing this task. The task will run only if the `run_if` condition is true.
The key is `task_key`, and the value is the name assigned to the dependent task.
"""
description: VariableOrOptional[str] = None
"""
An optional description for this task.
"""
disable_auto_optimization: VariableOrOptional[bool] = None
"""
An option to disable auto optimization in serverless
"""
disabled: VariableOrOptional[bool] = None
"""
:meta private: [EXPERIMENTAL]
An optional flag to disable the task. If set to true, the task will not run even if it is part of a job.
"""
email_notifications: VariableOrOptional[TaskEmailNotifications] = None
"""
An optional set of email addresses that is notified when runs of this task begin or complete as well as when this task is deleted. The default behavior is to not send any emails.
"""
environment_key: VariableOrOptional[str] = None
"""
The key that references an environment spec in a job. This field is required for Python script, Python wheel and dbt tasks when using serverless compute.
"""
existing_cluster_id: VariableOrOptional[str] = None
"""
If existing_cluster_id, the ID of an existing cluster that is used for all runs.
When running jobs or tasks on an existing cluster, you may need to manually restart
the cluster if it stops responding. We suggest running jobs and tasks on new clusters for
greater reliability
"""
for_each_task: VariableOrOptional[ForEachTask] = None
"""
The task executes a nested task for every input provided when the `for_each_task` field is present.
"""
gen_ai_compute_task: VariableOrOptional[GenAiComputeTask] = None
"""
:meta private: [EXPERIMENTAL]
"""
health: VariableOrOptional[JobsHealthRules] = None
job_cluster_key: VariableOrOptional[str] = None
"""
If job_cluster_key, this task is executed reusing the cluster specified in `job.settings.job_clusters`.
"""
libraries: VariableOrList[Library] = field(default_factory=list)
"""
An optional list of libraries to be installed on the cluster.
The default value is an empty list.
"""
max_retries: VariableOrOptional[int] = None
"""
An optional maximum number of times to retry an unsuccessful run. A run is considered to be unsuccessful if it completes with the `FAILED` result_state or `INTERNAL_ERROR` `life_cycle_state`. The value `-1` means to retry indefinitely and the value `0` means to never retry.
"""
min_retry_interval_millis: VariableOrOptional[int] = None
"""
An optional minimal interval in milliseconds between the start of the failed run and the subsequent retry run. The default behavior is that unsuccessful runs are immediately retried.
"""
new_cluster: VariableOrOptional[ClusterSpec] = None
"""
If new_cluster, a description of a new cluster that is created for each run.
"""
notebook_task: VariableOrOptional[NotebookTask] = None
"""
The task runs a notebook when the `notebook_task` field is present.
"""
notification_settings: VariableOrOptional[TaskNotificationSettings] = None
"""
Optional notification settings that are used when sending notifications to each of the `email_notifications` and `webhook_notifications` for this task.
"""
pipeline_task: VariableOrOptional[PipelineTask] = None
"""
The task triggers a pipeline update when the `pipeline_task` field is present. Only pipelines configured to use triggered more are supported.
"""
power_bi_task: VariableOrOptional[PowerBiTask] = None
"""
The task triggers a Power BI semantic model update when the `power_bi_task` field is present.
"""
python_wheel_task: VariableOrOptional[PythonWheelTask] = None
"""
The task runs a Python wheel when the `python_wheel_task` field is present.
"""
retry_on_timeout: VariableOrOptional[bool] = None
"""
An optional policy to specify whether to retry a job when it times out. The default behavior
is to not retry on timeout.
"""
run_if: VariableOrOptional[RunIf] = None
"""
An optional value specifying the condition determining whether the task is run once its dependencies have been completed.
* `ALL_SUCCESS`: All dependencies have executed and succeeded
* `AT_LEAST_ONE_SUCCESS`: At least one dependency has succeeded
* `NONE_FAILED`: None of the dependencies have failed and at least one was executed
* `ALL_DONE`: All dependencies have been completed
* `AT_LEAST_ONE_FAILED`: At least one dependency failed
* `ALL_FAILED`: ALl dependencies have failed
"""
run_job_task: VariableOrOptional[RunJobTask] = None
"""
The task triggers another job when the `run_job_task` field is present.
"""
spark_jar_task: VariableOrOptional[SparkJarTask] = None
"""
The task runs a JAR when the `spark_jar_task` field is present.
"""
spark_python_task: VariableOrOptional[SparkPythonTask] = None
"""
The task runs a Python file when the `spark_python_task` field is present.
"""
spark_submit_task: VariableOrOptional[SparkSubmitTask] = None
"""
[DEPRECATED] (Legacy) The task runs the spark-submit script when the spark_submit_task field is present. Databricks recommends using the spark_jar_task instead; see [Spark Submit task for jobs](/jobs/spark-submit).
"""
sql_task: VariableOrOptional[SqlTask] = None
"""
The task runs a SQL query or file, or it refreshes a SQL alert or a legacy SQL dashboard when the `sql_task` field is present.
"""
timeout_seconds: VariableOrOptional[int] = None
"""
An optional timeout applied to each run of this job task. A value of `0` means no timeout.
"""
webhook_notifications: VariableOrOptional[WebhookNotifications] = None
"""
A collection of system notification IDs to notify when runs of this task begin or complete. The default behavior is to not send any system notifications.
"""
@classmethod
def from_dict(cls, value: "TaskDict") -> "Self":
return _transform(cls, value)
def as_dict(self) -> "TaskDict":
return _transform_to_json_value(self) # type:ignore
class TaskDict(TypedDict, total=False):
""""""
task_key: VariableOr[str]
"""
A unique name for the task. This field is used to refer to this task from other tasks.
This field is required and must be unique within its parent job.
On Update or Reset, this field is used to reference the tasks to be updated or reset.
"""
clean_rooms_notebook_task: VariableOrOptional[CleanRoomsNotebookTaskParam]
"""
The task runs a [clean rooms](https://docs.databricks.com/clean-rooms/index.html) notebook
when the `clean_rooms_notebook_task` field is present.
"""
condition_task: VariableOrOptional[ConditionTaskParam]
"""
The task evaluates a condition that can be used to control the execution of other tasks when the `condition_task` field is present.
The condition task does not require a cluster to execute and does not support retries or notifications.
"""
dashboard_task: VariableOrOptional[DashboardTaskParam]
"""
The task refreshes a dashboard and sends a snapshot to subscribers.
"""
dbt_platform_task: VariableOrOptional[DbtPlatformTaskParam]
"""
:meta private: [EXPERIMENTAL]
"""
dbt_task: VariableOrOptional[DbtTaskParam]
"""
The task runs one or more dbt commands when the `dbt_task` field is present. The dbt task requires both Databricks SQL and the ability to use a serverless or a pro SQL warehouse.
"""
depends_on: VariableOrList[TaskDependencyParam]
"""
An optional array of objects specifying the dependency graph of the task. All tasks specified in this field must complete before executing this task. The task will run only if the `run_if` condition is true.
The key is `task_key`, and the value is the name assigned to the dependent task.
"""
description: VariableOrOptional[str]
"""
An optional description for this task.
"""
disable_auto_optimization: VariableOrOptional[bool]
"""
An option to disable auto optimization in serverless
"""
disabled: VariableOrOptional[bool]
"""
:meta private: [EXPERIMENTAL]
An optional flag to disable the task. If set to true, the task will not run even if it is part of a job.
"""
email_notifications: VariableOrOptional[TaskEmailNotificationsParam]
"""
An optional set of email addresses that is notified when runs of this task begin or complete as well as when this task is deleted. The default behavior is to not send any emails.
"""
environment_key: VariableOrOptional[str]
"""
The key that references an environment spec in a job. This field is required for Python script, Python wheel and dbt tasks when using serverless compute.
"""
existing_cluster_id: VariableOrOptional[str]
"""
If existing_cluster_id, the ID of an existing cluster that is used for all runs.
When running jobs or tasks on an existing cluster, you may need to manually restart
the cluster if it stops responding. We suggest running jobs and tasks on new clusters for
greater reliability
"""
for_each_task: VariableOrOptional[ForEachTaskParam]
"""
The task executes a nested task for every input provided when the `for_each_task` field is present.
"""
gen_ai_compute_task: VariableOrOptional[GenAiComputeTaskParam]
"""
:meta private: [EXPERIMENTAL]
"""
health: VariableOrOptional[JobsHealthRulesParam]
job_cluster_key: VariableOrOptional[str]
"""
If job_cluster_key, this task is executed reusing the cluster specified in `job.settings.job_clusters`.
"""
libraries: VariableOrList[LibraryParam]
"""
An optional list of libraries to be installed on the cluster.
The default value is an empty list.
"""
max_retries: VariableOrOptional[int]
"""
An optional maximum number of times to retry an unsuccessful run. A run is considered to be unsuccessful if it completes with the `FAILED` result_state or `INTERNAL_ERROR` `life_cycle_state`. The value `-1` means to retry indefinitely and the value `0` means to never retry.
"""
min_retry_interval_millis: VariableOrOptional[int]
"""
An optional minimal interval in milliseconds between the start of the failed run and the subsequent retry run. The default behavior is that unsuccessful runs are immediately retried.
"""
new_cluster: VariableOrOptional[ClusterSpecParam]
"""
If new_cluster, a description of a new cluster that is created for each run.
"""
notebook_task: VariableOrOptional[NotebookTaskParam]
"""
The task runs a notebook when the `notebook_task` field is present.
"""
notification_settings: VariableOrOptional[TaskNotificationSettingsParam]
"""
Optional notification settings that are used when sending notifications to each of the `email_notifications` and `webhook_notifications` for this task.
"""
pipeline_task: VariableOrOptional[PipelineTaskParam]
"""
The task triggers a pipeline update when the `pipeline_task` field is present. Only pipelines configured to use triggered more are supported.
"""
power_bi_task: VariableOrOptional[PowerBiTaskParam]
"""
The task triggers a Power BI semantic model update when the `power_bi_task` field is present.
"""
python_wheel_task: VariableOrOptional[PythonWheelTaskParam]
"""
The task runs a Python wheel when the `python_wheel_task` field is present.
"""
retry_on_timeout: VariableOrOptional[bool]
"""
An optional policy to specify whether to retry a job when it times out. The default behavior
is to not retry on timeout.
"""
run_if: VariableOrOptional[RunIfParam]
"""
An optional value specifying the condition determining whether the task is run once its dependencies have been completed.
* `ALL_SUCCESS`: All dependencies have executed and succeeded
* `AT_LEAST_ONE_SUCCESS`: At least one dependency has succeeded
* `NONE_FAILED`: None of the dependencies have failed and at least one was executed
* `ALL_DONE`: All dependencies have been completed
* `AT_LEAST_ONE_FAILED`: At least one dependency failed
* `ALL_FAILED`: ALl dependencies have failed
"""
run_job_task: VariableOrOptional[RunJobTaskParam]
"""
The task triggers another job when the `run_job_task` field is present.
"""
spark_jar_task: VariableOrOptional[SparkJarTaskParam]
"""
The task runs a JAR when the `spark_jar_task` field is present.
"""
spark_python_task: VariableOrOptional[SparkPythonTaskParam]
"""
The task runs a Python file when the `spark_python_task` field is present.
"""
spark_submit_task: VariableOrOptional[SparkSubmitTaskParam]
"""
[DEPRECATED] (Legacy) The task runs the spark-submit script when the spark_submit_task field is present. Databricks recommends using the spark_jar_task instead; see [Spark Submit task for jobs](/jobs/spark-submit).
"""
sql_task: VariableOrOptional[SqlTaskParam]
"""
The task runs a SQL query or file, or it refreshes a SQL alert or a legacy SQL dashboard when the `sql_task` field is present.
"""
timeout_seconds: VariableOrOptional[int]
"""
An optional timeout applied to each run of this job task. A value of `0` means no timeout.
"""
webhook_notifications: VariableOrOptional[WebhookNotificationsParam]
"""
A collection of system notification IDs to notify when runs of this task begin or complete. The default behavior is to not send any system notifications.
"""
TaskParam = TaskDict | Task