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 2020/06/14 11:08:46 UTC

[GitHub] [airflow] ashb commented on a change in pull request #9276: Add airflow upgrade_check command (MVP)

ashb commented on a change in pull request #9276:
URL: https://github.com/apache/airflow/pull/9276#discussion_r439817307



##########
File path: airflow/upgrade/rules/conn_type_is_not_nullable.py
##########
@@ -0,0 +1,43 @@
+# 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 shlex import quote
+
+from airflow.models import Connection
+from airflow.upgrade.rules.base_rule import BaseRule
+from airflow.utils.session import provide_session
+
+
+class ConnTypeIsNotNullableRule(BaseRule):
+
+    title = "Connection.conn_type is not nullable"
+
+    description = """\
+The `conn_type` column in the `connection` table must contain content. Previously, this rule was \
+enforced by application logic, but was not enforced by the database schema.
+
+If you made any modifications to the table directly, make sure you don't have null in the conn_type column.\
+"""
+
+    @provide_session
+    def check(self, session=None):
+        # invalid_connections = session.query(Connection).filter(Connection.conn_type.is_(None))
+        invalid_connections = [Connection(conn_id="AA")]
+        return (
+            f'Connection<id={quote(conn.id)}", conn_id={conn.conn_id}> have empty conn_type field.'

Review comment:
       `{conn.id!r}` seems more natural than shell quoting function.
   
   Though conn.id is an integer, so quoting it is not needed. Did you mean to do this on conn_id instead?

##########
File path: airflow/upgrade/formatters/base_formatter.py
##########
@@ -0,0 +1,33 @@
+# 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 abc import ABCMeta
+from typing import List
+
+from airflow.upgrade.problem import Problem
+from airflow.upgrade.rules.base_rule import BaseRule
+
+
+class BaseFormatter(metaclass=ABCMeta):

Review comment:
       Please can we not have one class per file - this isn't Java.
   
   All of these formatter classes would live in the same module.




----------------------------------------------------------------
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:
users@infra.apache.org