You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/29 15:37:32 UTC

[GitHub] [airflow] mrbaguvix commented on a change in pull request #16141: Add a calendar field to choose the execution date of the DAG when triggering it

mrbaguvix commented on a change in pull request #16141:
URL: https://github.com/apache/airflow/pull/16141#discussion_r641952075



##########
File path: airflow/www/views.py
##########
@@ -1499,15 +1501,23 @@ def trigger(self, session=None):
                 except TypeError:
                     flash("Could not pre-populate conf field due to non-JSON-serializable data-types")
             return self.render_template(
-                'airflow/trigger.html', dag_id=dag_id, origin=origin, conf=default_conf, doc_md=doc_md
+                'airflow/trigger.html',
+                dag_id=dag_id,
+                origin=origin,
+                conf=default_conf,
+                doc_md=doc_md,
+                form=form,
             )
 
         dag_orm = session.query(models.DagModel).filter(models.DagModel.dag_id == dag_id).first()
         if not dag_orm:
             flash(f"Cannot find dag {dag_id}")
             return redirect(origin)
 
-        execution_date = timezone.utcnow()
+        if request_execution_date is not None:
+            execution_date = timezone.parse(request_execution_date)
+        else:
+            execution_date = timezone.utcnow()

Review comment:
       i think this logic is unnecessary branching if we can default to `timezone.utcnow()` in `request.values.get` method.

##########
File path: airflow/www/views.py
##########
@@ -1483,13 +1483,15 @@ def trigger(self, session=None):
         dag_id = request.values.get('dag_id')
         origin = get_safe_url(request.values.get('origin'))
         request_conf = request.values.get('conf')
+        request_execution_date = request.values.get('execution_date', default=None)

Review comment:
       Why not `default=timezone.utcnow()` ?




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org