You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/06/15 07:11:45 UTC

[GitHub] [airflow] ephraimbuddy commented on a diff in pull request #23317: Add DagWarning model, and a check for missing pools

ephraimbuddy commented on code in PR #23317:
URL: https://github.com/apache/airflow/pull/23317#discussion_r897614763


##########
airflow/models/dagwarning.py:
##########
@@ -0,0 +1,93 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from enum import Enum
+
+from sqlalchemy import Column, ForeignKeyConstraint, Integer, String, Text, false
+
+from airflow.models.base import ID_LEN, Base
+from airflow.utils import timezone
+from airflow.utils.session import NEW_SESSION, provide_session
+from airflow.utils.sqlalchemy import UtcDateTime
+
+
+class DagWarning(Base):
+    """
+    A table to store DAG warnings.
+
+    DAG warnings are problems that don't rise to the level of failing the DAG parse
+    but which users should nonetheless be warned about.  These warnings are recorded
+    when parsing DAG and displayed on the Webserver in a flash message.
+    """
+
+    id = Column(
+        Integer, autoincrement=True, server_default='id'
+    )  # this default just signals to SQLA to defer to server

Review Comment:
   I think that if we use `merge` for updating items and `add` for adding new items we won't have issues with the surrogate key. We can still use `merge` for new items, we just need to ensure that the item is not already in `session` (see https://www.bookstack.cn/read/sqlalchemy-1.3/999f5d55791da984.md). Even the proposed solution will have an issue with `merge` if the item already exists in the session.
   
   Another thing is, would this table confuse other SQLAlchemy users? It feels like a hack to have an `id` field with a `server_default` value and an `autoincrement` set. If we want to use it, then we might need to make a note and also add a link for reference purposes why we need it.
   
   Also, it feels like we will also have issues reconciling the ORM and DB for this case.



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org