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/06/01 23:19:03 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #16030: Update `airflow tasks *` commands to lookup TaskInstances from DagRun Table

ephraimbuddy commented on a change in pull request #16030:
URL: https://github.com/apache/airflow/pull/16030#discussion_r643547588



##########
File path: airflow/cli/commands/task_command.py
##########
@@ -42,9 +45,26 @@
     get_dags,
     suppress_logs_and_warning,
 )
+from airflow.utils.dates import timezone
 from airflow.utils.log.logging_mixin import StreamLogWriter
 from airflow.utils.net import get_hostname
-from airflow.utils.session import create_session
+from airflow.utils.session import create_session, provide_session
+
+
+def _get_ti(dag, task, exec_date_or_run_id):
+    """Get the task instance through DagRun.run_id, if that fails, get the TI the old way"""
+    dag_run = dag.get_dagrun(run_id=exec_date_or_run_id)
+    if not dag_run:
+        try:
+            execution_date = timezone.parse(exec_date_or_run_id)
+            # print("Warning: execution_date will be removed in
+            # tasks command in the future. Please use DagRun.run_id")

Review comment:
       I'm not sure it's OK to print it right now. @ash




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