kaxil commented on code in PR #44972:
URL: https://github.com/apache/airflow/pull/44972#discussion_r1888228780


##########
airflow/serialization/serialized_objects.py:
##########
@@ -1870,3 +1871,55 @@ def _has_kubernetes() -> bool:
     except ImportError:
         HAS_KUBERNETES = False
     return HAS_KUBERNETES
+
+
+class LazyDeserializedDAG(pydantic.BaseModel):
+    """
+    Lazily build informatoin from the serialized DAG structure.
+
+    An object that will present "enough" of the DAG like interface to update 
DAG db models etc, without having
+    to deserialize the full DAG and Task hierarchy.
+    """
+
+    data: dict
+
+    NULLABLE_PROPERTIES: ClassVar[set[str]] = {
+        "is_paused_upon_creation",
+        "owner",
+        "dag_display_name",
+        "description",
+        "max_active_tasks",
+        "max_active_runs",
+        "max_consecutive_failed_dag_runs",
+        "owner_links",
+    }
+
+    @property
+    def hash(self) -> str:
+        from airflow.models.serialized_dag import SerializedDagModel
+
+        return SerializedDagModel.hash(self.data)
+
+    def next_dagrun_info(self, last):
+        return None
+
+    def __getattr__(self, name: str, /) -> Any:
+        if name in self.NULLABLE_PROPERTIES:
+            return self.data["dag"].get(name)
+        try:
+            return self.data["dag"][name]
+        except KeyError:
+            raise AttributeError(f"{type(self).__name__!r} object has no 
attribute {name!r}") from None
+
+    @property
+    def timetable(self):
+        return decode_timetable(self.data["dag"]["timetable"])
+
+    @property
+    def has_task_concurrency_limits(self):
+        return any(task.get("max_active_tis_per_dag") is not None for task in 
self.data["dag"]["tasks"])
+
+    if TYPE_CHECKING:
+        access_control: Mapping[str, Mapping[str, Collection[str]] | 
Collection[str]] | None = pydantic.Field(
+            init=False, default=None
+        )

Review Comment:
   This one seems weird -- do we need `pydantic.Field` part in the  
`TYPE_CHECKING` block?



-- 
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