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/11/22 13:54:13 UTC

[GitHub] [airflow] ashb commented on a change in pull request #18724: Support the use of `run_id` in `set_task_instance_state`(REST API)

ashb commented on a change in pull request #18724:
URL: https://github.com/apache/airflow/pull/18724#discussion_r754299710



##########
File path: airflow/api/common/experimental/mark_tasks.py
##########
@@ -104,6 +120,16 @@ def set_state(
     if dag is None:
         raise ValueError("Received tasks with no DAG")
 
+    if run_id is not None:
+        dr = (
+            session.query(DagRun.execution_date)
+            .filter(DagRun.run_id == run_id, DagRun.dag_id == dag.dag_id)
+            .one_or_none()
+        )
+        if dr is None:
+            raise ValueError(f"Run id {run_id} not found")
+        execution_date = dr.execution_date
+
     dates = get_execution_dates(dag, execution_date, future, past)

Review comment:
       Hmmm, if a run_id is given, we should really just use that to look up things, rather than convert it back to a date.




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