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/11 07:16:24 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #19353: Introduce DagRun action to change state to queued.

uranusjr commented on a change in pull request #19353:
URL: https://github.com/apache/airflow/pull/19353#discussion_r747255613



##########
File path: airflow/www/views.py
##########
@@ -3977,26 +3978,37 @@ class DagRunModelView(AirflowPrivilegeVerifierModelView):
 
     @action('muldelete', "Delete", "Are you sure you want to delete selected records?", single=False)
     @action_has_dag_edit_access
-    @provide_session
-    def action_muldelete(self, items, session=None):
+    def action_muldelete(self, items: List[DagRun]):
         """Multiple delete."""
         self.datamodel.delete_all(items)
         self.update_redirect()
         return redirect(self.get_redirect())
 
+    @action('set_queued', "Set state to 'queued'", '', single=False)
+    @action_has_dag_edit_access
+    def action_set_queued(self, drs: List[DagRun]):
+        """Set state to queued."""
+        return self.set_dag_runs_to_active_state(drs, State.QUEUED)
+
     @action('set_running', "Set state to 'running'", '', single=False)
     @action_has_dag_edit_access
-    @provide_session
-    def action_set_running(self, drs, session=None):
+    def action_set_running(self, drs: List[DagRun]):
         """Set state to running."""
+        return self.set_dag_runs_to_active_state(drs, State.RUNNING)
+
+    @provide_session
+    def set_dag_runs_to_active_state(self, drs: List[DagRun], state: str, session=None):
+        if state not in [State.RUNNING, State.QUEUED]:
+            raise ValueError("This routine only supports Running and Queued.")

Review comment:
       I feel we should
   
   1. Make this a private name (with an underscore prefix)
   2. Instead of checking explicitly, just add a docstring saying this currently is only designed to work with `RUNNING` and `QUEUED`.
   
   This funtion is not supposed to be exposed to the user, so we should make it more flexible for contributors to work on this function, instead of guarding people “on the same team”.




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