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 2022/09/14 19:38:52 UTC

[GitHub] [airflow] dimberman commented on a diff in pull request #26400: Create a more efficient airflow dag test command that also has better local logging

dimberman commented on code in PR #26400:
URL: https://github.com/apache/airflow/pull/26400#discussion_r971225589


##########
airflow/cli/commands/dag_command.py:
##########
@@ -497,6 +523,60 @@ def dag_test(args, session=None):
             print(dot_graph.source)
 
 
+@provide_session
+def _run_task(ti: TaskInstance, session=None):
+    """
+    Run a single task instance, and push result to Xcom for downstream tasks. Bypasses a lot of
+    extra steps used in `task.run` to keep our local running as fast as possible
+    Args:
+        ti: TaskInstance to run
+    """
+    current_task = ti.render_templates(ti.get_template_context())
+    log.info("*****************************************************")
+    log.info("Running task %s", current_task.task_id)
+    try:
+        xcom_value = current_task.execute(context=ti.get_template_context())

Review Comment:
   @ashb I agree on using the _run_raw_task function, but ironically the test_mode might not be the best idea here. test_mode prevents us from recording passing/failure in the database, and without that state we won't know when to run downstream tasks.



-- 
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: commits-unsubscribe@airflow.apache.org

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