varaprasadregani commented on PR #75429:
URL: https://github.com/apache/airflow/pull/75429#issuecomment-7198667471
Tested this branch merged onto current main (clean merge), using the use
case from #46563: a `DatabricksWorkflowTaskGroup` with an Airflow-templated job
parameter in `extra_job_params`, and a `DatabricksTaskOperator` whose
`task_config` mixes an Airflow template with an escaped Databricks dynamic
value reference. `test_databricks.py` and `test_databricks_workflow.py` pass
(356).
Without this PR, launch sends both strings unrendered:
```
{"p": "{% raw %}{{ job.parameters.my_param }}{% endraw %}", "q": "{{
params.my_param }}"}
```
With this PR:
```
{"p": "{{ job.parameters.my_param }}", "q": "run-1"}
```
A second `create_workflow_json` call with a different context gives
`"run-2"`, the member's own `task_config` is unchanged after launch, and its
later render on the worker produces the same Databricks reference without
error. Operators that remove `task_config` from `template_fields` through a
cluster policy behave as before.
A few things I noticed:
1. **Templated retry args still fail at launch.** The template fields are
rendered on `operator_proxy`, but the payload still uses
`self._retry_settings()`, so `max_retries="{{ params.r }}"` raises `ValueError:
invalid literal for int() with base 10: '{{ params.r }}'` on the launch task.
This already fails on main, but it seems in scope here since `max_retries`,
`min_retry_interval_millis` and `retry_on_timeout` are template fields. Using
the proxy fixes it locally (launch then sends `"max_retries": 2`, tests still
pass):
```diff
else:
+ operator_proxy = self
base_task_json = self._get_task_base_json()
else:
+ operator_proxy = self
base_task_json = self._get_task_base_json()
...
- **self._retry_settings(),
+ **operator_proxy._retry_settings(),
```
A test with a templated `max_retries` inside a workflow group would cover it.
2. **`task` in the context is the launch task.** `{{ task.task_id }}` in a
member's `task_config` renders as `<group_id>.launch` with no error. Would it
make sense to render with a copy of the context where `task` is the member?
Otherwise it could go in the docstring note next to `ti`.
3. **Where unescaped Databricks references fail.** References in Databricks'
own syntax (`{{ job.parameters.x }}`, `{{ tasks.y.values.z }}`, `{{ task.name
}}`) left unescaped in a templated `task_config` would now raise
`UndefinedError` on the launch task, before the job is reset or run, instead of
on the member task. That's arguably better, but the error names
`_CreateDatabricksWorkflowOperator`, which may confuse users. It might be worth
a changelog note that these references need `{% raw %}`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]