Skip to content

Commit

Permalink
Add note about params on trigger DAG page (apache#18166)
Browse files Browse the repository at this point in the history
  • Loading branch information
msumit authored Sep 12, 2021
1 parent 15a9945 commit d7aed84
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
7 changes: 7 additions & 0 deletions airflow/www/templates/airflow/trigger.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ <h2>Trigger DAG: {{ dag_id }}</h2>
</div>
<p>
To access configuration in your DAG use <code>{{ '{{ dag_run.conf }}' }}</code>.
{% if is_dag_run_conf_overrides_params %}
As <code>core.dag_run_conf_overrides_params</code> is set to <code>True</code>, so passing any configuration
here will override task params which can be accessed via <code>{{ '{{ params }}' }}</code>.
{% else %}
As <code>core.dag_run_conf_overrides_params</code> is set to <code>False</code>, so passing any configuration
here won't override task params.
{% endif %}
</p>
<div class="form-group">
<label class="switch-label">
Expand Down
23 changes: 20 additions & 3 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,7 @@ def trigger(self, session=None):
unpause = request.values.get('unpause')
request_conf = request.values.get('conf')
request_execution_date = request.values.get('execution_date', default=timezone.utcnow().isoformat())
is_dag_run_conf_overrides_params = conf.getboolean('core', 'dag_run_conf_overrides_params')

if request.method == 'GET':
# Populate conf textarea with conf requests parameter, or dag.params
Expand All @@ -1648,6 +1649,7 @@ def trigger(self, session=None):
conf=default_conf,
doc_md=doc_md,
form=form,
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
)

dag_orm = session.query(models.DagModel).filter(models.DagModel.dag_id == dag_id).first()
Expand All @@ -1661,7 +1663,12 @@ def trigger(self, session=None):
flash("Invalid execution date", "error")
form = DateTimeForm(data={'execution_date': timezone.utcnow().isoformat()})
return self.render_template(
'airflow/trigger.html', dag_id=dag_id, origin=origin, conf=request_conf, form=form
'airflow/trigger.html',
dag_id=dag_id,
origin=origin,
conf=request_conf,
form=form,
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
)

dr = DagRun.find(dag_id=dag_id, execution_date=execution_date, run_type=DagRunType.MANUAL)
Expand All @@ -1677,13 +1684,23 @@ def trigger(self, session=None):
flash("Invalid JSON configuration, must be a dict", "error")
form = DateTimeForm(data={'execution_date': execution_date})
return self.render_template(
'airflow/trigger.html', dag_id=dag_id, origin=origin, conf=request_conf, form=form
'airflow/trigger.html',
dag_id=dag_id,
origin=origin,
conf=request_conf,
form=form,
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
)
except json.decoder.JSONDecodeError:
flash("Invalid JSON configuration, not parseable", "error")
form = DateTimeForm(data={'execution_date': execution_date})
return self.render_template(
'airflow/trigger.html', dag_id=dag_id, origin=origin, conf=request_conf, form=form
'airflow/trigger.html',
dag_id=dag_id,
origin=origin,
conf=request_conf,
form=form,
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
)

dag = current_app.dag_bag.get_dag(dag_id)
Expand Down

0 comments on commit d7aed84

Please sign in to comment.