|
76 | 76 | get_schedule_key(): "0 3 * * *", |
77 | 77 | "tags": ["tag1", "tag2"], |
78 | 78 | "render_template_as_native_obj": True, |
79 | | - "tasks": { |
80 | | - "task_1": { |
| 79 | + "tasks": [ |
| 80 | + { |
| 81 | + "task_id": "task_1", |
81 | 82 | "operator": get_bash_operator_path(), |
82 | 83 | "bash_command": "echo 1", |
83 | 84 | "execution_timeout_secs": 5, |
84 | 85 | }, |
85 | | - "task_2": { |
| 86 | + { |
| 87 | + "task_id": "task_2", |
86 | 88 | "operator": get_bash_operator_path(), |
87 | 89 | "bash_command": "echo 2", |
88 | 90 | "dependencies": ["task_1"], |
89 | 91 | }, |
90 | | - "task_3": { |
| 92 | + { |
| 93 | + "task_id": "task_3", |
91 | 94 | "operator": get_bash_operator_path(), |
92 | 95 | "bash_command": "echo 3", |
93 | 96 | "dependencies": ["task_1"], |
94 | 97 | }, |
95 | | - }, |
| 98 | + ], |
96 | 99 | } |
97 | 100 | DAG_CONFIG_TASK_GROUP = { |
98 | 101 | "default_args": {"owner": "custom_owner"}, |
99 | 102 | get_schedule_key(): "0 3 * * *", |
100 | | - "task_groups": { |
101 | | - "task_group_1": { |
| 103 | + "task_groups": [ |
| 104 | + { |
| 105 | + "group_name": "task_group_1", |
102 | 106 | "tooltip": "this is a task group", |
103 | 107 | "dependencies": ["task_1"], |
104 | 108 | }, |
105 | | - "task_group_2": { |
| 109 | + { |
| 110 | + "group_name": "task_group_2", |
106 | 111 | "dependencies": ["task_group_1"], |
107 | 112 | }, |
108 | | - "task_group_3": {}, |
109 | | - }, |
110 | | - "tasks": { |
111 | | - "task_1": { |
| 113 | + { |
| 114 | + "group_name": "task_group_3", |
| 115 | + }, |
| 116 | + ], |
| 117 | + "tasks": [ |
| 118 | + { |
| 119 | + "task_id": "task_1", |
112 | 120 | "operator": get_bash_operator_path(), |
113 | 121 | "bash_command": "echo 1", |
114 | 122 | }, |
115 | | - "task_2": { |
| 123 | + { |
| 124 | + "task_id": "task_2", |
116 | 125 | "operator": get_bash_operator_path(), |
117 | 126 | "bash_command": "echo 2", |
118 | 127 | "task_group_name": "task_group_1", |
119 | 128 | }, |
120 | | - "task_3": { |
| 129 | + { |
| 130 | + "task_id": "task_3", |
121 | 131 | "operator": get_bash_operator_path(), |
122 | 132 | "bash_command": "echo 3", |
123 | 133 | "task_group_name": "task_group_1", |
124 | 134 | "dependencies": ["task_2"], |
125 | 135 | }, |
126 | | - "task_4": { |
| 136 | + { |
| 137 | + "task_id": "task_4", |
127 | 138 | "operator": get_bash_operator_path(), |
128 | 139 | "bash_command": "echo 4", |
129 | 140 | "dependencies": ["task_group_1"], |
130 | 141 | }, |
131 | | - "task_5": { |
| 142 | + { |
| 143 | + "task_id": "task_5", |
132 | 144 | "operator": get_bash_operator_path(), |
133 | 145 | "bash_command": "echo 5", |
134 | 146 | "task_group_name": "task_group_2", |
135 | 147 | }, |
136 | | - "task_6": { |
| 148 | + { |
| 149 | + "task_id": "task_6", |
137 | 150 | "operator": get_bash_operator_path(), |
138 | 151 | "bash_command": "echo 6", |
139 | 152 | "task_group_name": "task_group_2", |
140 | 153 | "dependencies": ["task_5"], |
141 | 154 | }, |
142 | | - }, |
| 155 | + ], |
143 | 156 | } |
144 | 157 | DAG_CONFIG_DYNAMIC_TASK_MAPPING = { |
145 | 158 | "default_args": {"owner": "custom_owner"}, |
146 | 159 | "description": "This is an example dag with dynamic task mapping", |
147 | 160 | get_schedule_key(): "0 4 * * *", |
148 | | - "tasks": { |
149 | | - "request": { |
| 161 | + "tasks": [ |
| 162 | + { |
| 163 | + "task_id": "request", |
150 | 164 | "operator": get_python_operator_path(), |
151 | 165 | "python_callable_name": "example_task_mapping", |
152 | 166 | "python_callable_file": os.path.realpath(__file__), |
153 | 167 | }, |
154 | | - "process_1": { |
| 168 | + { |
| 169 | + "task_id": "process_1", |
155 | 170 | "operator": get_python_operator_path(), |
156 | 171 | "python_callable_name": "expand_task", |
157 | 172 | "python_callable_file": os.path.realpath(__file__), |
158 | 173 | "partial": {"op_kwargs": {"test_id": "test"}}, |
159 | 174 | "expand": {"op_args": {"request_output": "request.output"}}, |
160 | 175 | }, |
161 | | - }, |
| 176 | + ], |
162 | 177 | } |
163 | 178 |
|
164 | 179 | DAG_CONFIG_ML = { |
|
205 | 220 | }, |
206 | 221 | "on_failure_callback_name": "print_context_callback", |
207 | 222 | "on_failure_callback_file": __file__, |
208 | | - "tasks": { |
209 | | - "task_1": { # Make sure that default_args are applied to this Task |
| 223 | + "tasks": [ |
| 224 | + { # Make sure that default_args are applied to this Task |
| 225 | + "task_id": "task_1", |
210 | 226 | "operator": get_bash_operator_path(), |
211 | 227 | "bash_command": "echo 1", |
212 | 228 | "execution_timeout_secs": 5, |
213 | 229 | "on_failure_callback_name": "print_context_callback", |
214 | 230 | "on_failure_callback_file": __file__, |
215 | 231 | } |
216 | | - }, |
| 232 | + ], |
217 | 233 | } |
218 | 234 |
|
219 | 235 | DAG_CONFIG_TASK_GROUP_WITH_CALLBACKS = { |
|
226 | 242 | }, |
227 | 243 | }, |
228 | 244 | get_schedule_key(): "0 3 * * *", |
229 | | - "task_groups": { |
230 | | - "task_group_1": { |
| 245 | + "task_groups": [ |
| 246 | + { |
| 247 | + "group_name": "task_group_1", |
231 | 248 | "tooltip": "this is a task group", |
232 | 249 | "default_args": { |
233 | 250 | "on_execute_callback": f"{__name__}.print_context_callback", |
|
237 | 254 | "on_skip_callback": f"{__name__}.print_context_callback", # Throwing this in for good measure |
238 | 255 | }, |
239 | 256 | }, |
240 | | - }, |
241 | | - "tasks": { |
242 | | - "task_1": { |
| 257 | + ], |
| 258 | + "tasks": [ |
| 259 | + { |
| 260 | + "task_id": "task_1", |
243 | 261 | "operator": get_bash_operator_path(), |
244 | 262 | "bash_command": "echo 1", |
245 | 263 | "task_group_name": "task_group_1", |
246 | 264 | }, |
247 | | - "task_2": { |
| 265 | + { |
| 266 | + "task_id": "task_2", |
248 | 267 | "operator": get_bash_operator_path(), |
249 | 268 | "bash_command": "echo 2", |
250 | 269 | "task_group_name": "task_group_1", |
|
254 | 273 | "param_2": "value_2", |
255 | 274 | }, |
256 | 275 | }, |
257 | | - "task_3": { |
| 276 | + { |
| 277 | + "task_id": "task_3", |
258 | 278 | "operator": get_bash_operator_path(), |
259 | 279 | "bash_command": "echo 3", |
260 | 280 | "task_group_name": "task_group_1", |
|
264 | 284 | # - String with no parameters |
265 | 285 | # - String with parameters |
266 | 286 | # - File name and path |
267 | | - "task_4": { |
| 287 | + { |
| 288 | + "task_id": "task_4", |
268 | 289 | "operator": get_bash_operator_path(), |
269 | 290 | "bash_command": "echo 4", |
270 | 291 | "dependencies": ["task_group_1"], |
|
277 | 298 | "on_failure_callback_name": "print_context_callback", |
278 | 299 | "on_failure_callback_file": __file__, |
279 | 300 | }, |
280 | | - }, |
| 301 | + ], |
281 | 302 | } |
282 | 303 |
|
283 | 304 |
|
@@ -313,23 +334,26 @@ def test_get_dag_params(): |
313 | 334 | "dagrun_timeout": datetime.timedelta(seconds=600), |
314 | 335 | "render_template_as_native_obj": True, |
315 | 336 | "tags": ["tag1", "tag2"], |
316 | | - "tasks": { |
317 | | - "task_1": { |
| 337 | + "tasks": [ |
| 338 | + { |
| 339 | + "task_id": "task_1", |
318 | 340 | "operator": get_bash_operator_path(), |
319 | 341 | "bash_command": "echo 1", |
320 | 342 | "execution_timeout_secs": 5, |
321 | 343 | }, |
322 | | - "task_2": { |
| 344 | + { |
| 345 | + "task_id": "task_2", |
323 | 346 | "operator": get_bash_operator_path(), |
324 | 347 | "bash_command": "echo 2", |
325 | 348 | "dependencies": ["task_1"], |
326 | 349 | }, |
327 | | - "task_3": { |
| 350 | + { |
| 351 | + "task_id": "task_3", |
328 | 352 | "operator": get_bash_operator_path(), |
329 | 353 | "bash_command": "echo 3", |
330 | 354 | "dependencies": ["task_1"], |
331 | 355 | }, |
332 | | - }, |
| 356 | + ], |
333 | 357 | } |
334 | 358 | actual = td.get_dag_params() |
335 | 359 | assert actual == expected |
@@ -572,47 +596,56 @@ def test_get_dag_params_dag_with_task_group(): |
572 | 596 | "retry_delay": datetime.timedelta(seconds=300), |
573 | 597 | }, |
574 | 598 | get_schedule_key(): "0 3 * * *", |
575 | | - "task_groups": { |
576 | | - "task_group_1": { |
| 599 | + "task_groups": [ |
| 600 | + { |
| 601 | + "group_name": "task_group_1", |
577 | 602 | "tooltip": "this is a task group", |
578 | 603 | "dependencies": ["task_1"], |
579 | 604 | }, |
580 | | - "task_group_2": {"dependencies": ["task_group_1"]}, |
581 | | - "task_group_3": {}, |
582 | | - }, |
583 | | - "tasks": { |
584 | | - "task_1": { |
| 605 | + {"group_name": "task_group_2", "dependencies": ["task_group_1"]}, |
| 606 | + { |
| 607 | + "group_name": "task_group_3", |
| 608 | + }, |
| 609 | + ], |
| 610 | + "tasks": [ |
| 611 | + { |
| 612 | + "task_id": "task_1", |
585 | 613 | "operator": get_bash_operator_path(), |
586 | 614 | "bash_command": "echo 1", |
587 | 615 | }, |
588 | | - "task_2": { |
| 616 | + { |
| 617 | + "task_id": "task_2", |
589 | 618 | "operator": get_bash_operator_path(), |
590 | 619 | "bash_command": "echo 2", |
591 | 620 | "task_group_name": "task_group_1", |
592 | 621 | }, |
593 | | - "task_3": { |
| 622 | + { |
| 623 | + "task_id": "task_3", |
594 | 624 | "operator": get_bash_operator_path(), |
595 | 625 | "bash_command": "echo 3", |
596 | 626 | "task_group_name": "task_group_1", |
597 | 627 | "dependencies": ["task_2"], |
598 | 628 | }, |
599 | | - "task_4": { |
| 629 | + { |
| 630 | + "task_id": "task_4", |
600 | 631 | "operator": get_bash_operator_path(), |
601 | 632 | "bash_command": "echo 4", |
602 | 633 | "dependencies": ["task_group_1"], |
603 | 634 | }, |
604 | | - "task_5": { |
| 635 | + { |
| 636 | + "task_id": "task_5", |
605 | 637 | "operator": get_bash_operator_path(), |
606 | 638 | "bash_command": "echo 5", |
607 | 639 | "task_group_name": "task_group_2", |
608 | 640 | }, |
609 | | - "task_6": { |
| 641 | + { |
| 642 | + "task_id": "task_6", |
610 | 643 | "operator": get_bash_operator_path(), |
611 | 644 | "bash_command": "echo 6", |
612 | 645 | "task_group_name": "task_group_2", |
613 | 646 | "dependencies": ["task_5"], |
614 | 647 | }, |
615 | | - }, |
| 648 | + ], |
616 | 649 | "concurrency": 1, |
617 | 650 | "max_active_runs": 1, |
618 | 651 | "dag_id": "test_dag", |
|
0 commit comments