[GitHub] [airflow] uranusjr commented on a diff in pull request #22699: add allow_manual DAG argument to prevent scheduled DAGs from being triggered manually
uranusjr commented on code in PR #22699: URL: https://github.com/apache/airflow/pull/22699#discussion_r847768433 ## airflow/exceptions.py: ## @@ -298,3 +298,7 @@ def __repr__(self) -> str: class TaskDeferralError(AirflowException): """Raised when a task failed during deferral for some reason.""" + + +class DAGDisallowManual(AirflowException): Review Comment: ```suggestion class ManualDAGRunDisallowed(AirflowException): ``` seems to read better forme. -- 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-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #22699: add allow_manual DAG argument to prevent scheduled DAGs from being triggered manually
uranusjr commented on code in PR #22699: URL: https://github.com/apache/airflow/pull/22699#discussion_r845733347 ## airflow/models/dag.py: ## @@ -2280,6 +2284,12 @@ def create_dagrun( "Creating DagRun needs either `run_id` or both `run_type` and `execution_date`" ) +if not self.allow_manual and run_type == DagRunType.MANUAL: +raise AirflowException( +f"Cannot manually trigger DAG {self.dag_id}, because 'allow_manual' is " +f"set to {self.allow_manual}" +) Review Comment: Use a dedicated exception subclass here. You will need to catch this in a lot of places, and using `AirflowException` directly will make things very difficult. -- 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-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org