#
#
from __future__ import annotations
from datetime import datetime
from typing import TYPE_CHECKING, Any, Iterable, List, Optional
from pydantic import BaseModel as BaseModelPydantic, PlainSerializer, PlainValidator, ValidationInfo
from typing_extensions import Annotated
from airflow import DAG
from airflow.serialization.pydantic.dataset import DatasetEventPydantic
from airflow.utils.session import NEW_SESSION, provide_session
if TYPE_CHECKING:
    from sqlalchemy.orm import Session
    from airflow.jobs.scheduler_job_runner import TI
    from airflow.serialization.pydantic.taskinstance import TaskInstancePydantic
    from airflow.utils.state import TaskInstanceState
def serialize_operator(x: DAG) -> dict:
    from airflow.serialization.serialized_objects import SerializedDAG
    return SerializedDAG.serialize_dag(x)
def validated_operator(x: DAG | dict[str, Any], _info: ValidationInfo) -> Any:
    from airflow.serialization.serialized_objects import SerializedDAG
    if isinstance(x, DAG):
        return x
    return SerializedDAG.deserialize_dag(x)
PydanticDag = Annotated[
    DAG,
    PlainValidator(validated_operator),
    PlainSerializer(serialize_operator, return_type=dict),
]
class DagRunPydantic(BaseModelPydantic):