mik-laj commented on a change in pull request #7806: Decouple DAG from DagBag -
remove cyclic imports
URL: https://github.com/apache/airflow/pull/7806#discussion_r396114950
##########
File path: airflow/models/dag.py
##########
@@ -1850,31 +1562,27 @@ def create_dagrun(self,
def set_is_paused(self,
is_paused: bool,
including_subdags: bool = True,
- store_serialized_dags: bool = False,
session=None) -> None:
"""
Pause/Un-pause a DAG.
:param is_paused: Is the DAG paused
:param including_subdags: whether to include the DAG's subdags
- :param store_serialized_dags: whether to serialize DAGs & store it in
DB
:param session: session
"""
- dag_ids = [self.dag_id] # type: List[str]
+ filter_query = [
+ DagModel.dag_id.in_(self.dag_id),
+ ]
if including_subdags:
- dag = self.get_dag(store_serialized_dags)
- if dag is None:
- raise DagNotFound("Dag id {} not found".format(self.dag_id))
- subdags = dag.subdags
- dag_ids.extend([subdag.dag_id for subdag in subdags])
- dag_models =
session.query(DagModel).filter(DagModel.dag_id.in_(dag_ids)).all()
- try:
- for dag_model in dag_models:
- dag_model.is_paused = is_paused
- session.commit()
- except Exception:
- session.rollback()
- raise
+ filter_query.append(
+ DagModel.root_dag_id.in_(self.dag_id)
Review comment:
```suggestion
DagModel.root_dag_id == self.dag_id
```
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services