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/11/11 11:16:52 UTC

[GitHub] [airflow] potiuk commented on a change in pull request #12265: Providers in extras are properly configured and verified

potiuk commented on a change in pull request #12265:
URL: https://github.com/apache/airflow/pull/12265#discussion_r521287434



##########
File path: scripts/ci/pre_commit/pre_commit_check_extras_have_providers.py
##########
@@ -0,0 +1,68 @@
+#!/usr/bin/env python3
+# 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.
+
+# Check if the extras have providers defined.
+import os
+import sys
+from os.path import dirname
+from textwrap import wrap
+from typing import List
+
+AIRFLOW_SOURCES_DIR = os.path.abspath(os.path.join(dirname(__file__), os.pardir, os.pardir, os.pardir))
+
+sys.path.insert(0, AIRFLOW_SOURCES_DIR)
+# flake8: noqa: F401
+# pylint: disable=wrong-import-position
+from setup import EXTRAS_PROVIDERS_PACKAGES  # noqa
+
+sys.path.append(AIRFLOW_SOURCES_DIR)
+
+
+def get_provider_directory(provider: str):
+    return os.path.join(AIRFLOW_SOURCES_DIR, "airflow", "providers", *provider.split('.'))
+
+
+def check_all_providers() -> List[str]:
+    errors: List[str] = []
+    for extra, providers in EXTRAS_PROVIDERS_PACKAGES.items():
+        for provider in providers:
+            provider_directory = get_provider_directory(provider)
+            if not os.path.isdir(provider_directory):
+                errors.append(
+                    f"The {extra} has provider {provider} that has" f" missing {provider_directory} directory"

Review comment:
       Ah. Blacks's joining the lines :)




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