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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to