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/09/09 08:35:28 UTC
[GitHub] [airflow] potiuk opened a new pull request #10822: POC/WIP on provider package discovery mechanism
potiuk opened a new pull request #10822:
URL: https://github.com/apache/airflow/pull/10822
Here is a POC/WIP of dynamic discovery for Provider packages . I will write message shortly about it (1.10 backport is coming in a moment)
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
----------------------------------------------------------------
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
[GitHub] [airflow] potiuk commented on a change in pull request #10822: POC/WIP on provider package discovery mechanism
Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #10822:
URL: https://github.com/apache/airflow/pull/10822#discussion_r486418481
##########
File path: airflow/get_provider_info.py
##########
@@ -0,0 +1,81 @@
+# 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.
+
+import importlib
+import pkgutil
+
+
+def get_provider_info(conn_type_to_hook, connection_types):
Review comment:
Sure - it's really a POC which I prepared quickly - happy to move it there.
----------------------------------------------------------------
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
[GitHub] [airflow] turbaszek commented on a change in pull request #10822: POC/WIP on provider package discovery mechanism
Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10822:
URL: https://github.com/apache/airflow/pull/10822#discussion_r485565633
##########
File path: airflow/get_provider_info.py
##########
@@ -0,0 +1,81 @@
+# 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.
+
+import importlib
+import pkgutil
+
+
+def get_provider_info(conn_type_to_hook, connection_types):
+ """
+ Retrieves provider information and adds information to hooks/connection
+ :param conn_type_to_hook: dictionary of mapping for connections -> hooks
+ :param connection_types: array of connection types
+ :return: dictionary metadata about all providers installed
+ """
+ def ignore(_):
+ pass
+
+ def update_or_replace_connection_type(core_connection_types, provider_connection_types):
+ """
+ Updates or replaces all core connection types with those that come from a provider.
+ If same connection type is found in core types it is replaced with the provider one,
+ otherwise the provider connection type is appended to the list.
+
+ :param core_connection_types: all core connection tepes
+ :type core_connection_types List[Tuple]
+ :param provider_connection_types: provider connection types
+ :type provider_connection_types List[Tuple]
+ :return: None
+ """
+ for provider_connection_type in provider_connection_types:
+ for index, core_connection_type in enumerate(connection_types):
+ if core_connection_type[0] == provider_connection_type[0]:
+ connection_types[index] = provider_connection_type
+ break
+ core_connection_types.append(provider_connection_type)
+ try:
+ from airflow import providers
+ except ImportError:
+ print("No providers are available!")
+ return {}
+
+ providers_path = providers.__path__
+ providers_name = providers.__name__
+ provider_dict = {}
+
+ for (_, name, ispkg) in pkgutil.walk_packages(path=providers_path,
+ prefix=providers_name + ".",
+ onerror=ignore):
+ try:
+ if ispkg:
Review comment:
```suggestion
onerror=ignore):
if not ispkg:
continue
try:
```
WDYT?
----------------------------------------------------------------
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
[GitHub] [airflow] potiuk closed pull request #10822: POC/WIP on provider package discovery mechanism
Posted by GitBox <gi...@apache.org>.
potiuk closed pull request #10822:
URL: https://github.com/apache/airflow/pull/10822
----------------------------------------------------------------
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
[GitHub] [airflow] potiuk commented on pull request #10822: POC/WIP on provider package discovery mechanism
Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #10822:
URL: https://github.com/apache/airflow/pull/10822#issuecomment-720747783
----------------------------------------------------------------
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
[GitHub] [airflow] ashb commented on pull request #10822: POC/WIP on provider package discovery mechanism
Posted by GitBox <gi...@apache.org>.
ashb commented on pull request #10822:
URL: https://github.com/apache/airflow/pull/10822#issuecomment-721015586
----------------------------------------------------------------
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
[GitHub] [airflow] ashb commented on a change in pull request #10822: POC/WIP on provider package discovery mechanism
Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #10822:
URL: https://github.com/apache/airflow/pull/10822#discussion_r486188679
##########
File path: airflow/get_provider_info.py
##########
@@ -0,0 +1,81 @@
+# 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.
+
+import importlib
+import pkgutil
+
+
+def get_provider_info(conn_type_to_hook, connection_types):
Review comment:
This feels similar to existing code in PluginsManager, and serves a similar purpose. What do you think about move this code in to there?
----------------------------------------------------------------
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