uranusjr commented on code in PR #28900: URL: https://github.com/apache/airflow/pull/28900#discussion_r1264132960
########## airflow/models/serialized_dag.py: ########## @@ -395,3 +398,18 @@ def get_dag_dependencies(cls, session: Session = NEW_SESSION) -> dict[str, list[ else: iterator = session.query(cls.dag_id, func.json_extract_path(cls._data, "dag", "dag_dependencies")) return {dag_id: [DagDependency(**d) for d in (deps_data or [])] for dag_id, deps_data in iterator} + + @staticmethod + @internal_api_call + @provide_session + def get_serialized_dag(dag_id: str, task_id: str, session: Session = NEW_SESSION) -> Operator | None: + from airflow.models.serialized_dag import SerializedDagModel + + try: + model = session.get(SerializedDagModel, dag_id) + if model: + return model.dag.get_task(task_id) + except (exc.NoResultFound, TaskNotFound): + pass Review Comment: ```suggestion try: model = session.get(SerializedDagModel, dag_id) except exc.NoResultFound: return None try: return model.dag.get_task(task_id) except TaskNotFound: return None ``` -- 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