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/09/30 05:52:34 UTC
[GitHub] [airflow] dstandish opened a new pull request, #26793: Add MIN_AIRFLOW_VERSION constant to all providers
dstandish opened a new pull request, #26793:
URL: https://github.com/apache/airflow/pull/26793
Ultimately the goal is to be able to add checks in the code which help to ensure that we actually remove code that should be removed when provider's min airflow version is bumped. This will help make this possible. We can already get the info from the ProviderManager parser, but having it rendered out into a constant is much simpler, cleaner, more intuitive, and faster.
--
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
[GitHub] [airflow] dstandish commented on pull request #26793: Add MIN_AIRFLOW_VERSION constant to all providers
Posted by GitBox <gi...@apache.org>.
dstandish commented on PR #26793:
URL: https://github.com/apache/airflow/pull/26793#issuecomment-1265739665
Yeah i'm ok not merging this, snowflake is bumping major version shortly anyway, and.... i realized, in some cases, it's possible to add this kind of check not in the code but in the unit tests, which can achieve the same effect.
--
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
[GitHub] [airflow] dstandish closed pull request #26793: Add MIN_AIRFLOW_VERSION constant to all providers
Posted by GitBox <gi...@apache.org>.
dstandish closed pull request #26793: Add MIN_AIRFLOW_VERSION constant to all providers
URL: https://github.com/apache/airflow/pull/26793
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #26793: Add MIN_AIRFLOW_VERSION constant to all providers
Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #26793:
URL: https://github.com/apache/airflow/pull/26793#discussion_r984387729
##########
scripts/ci/pre_commit/pre_commit_check_provider_min_airflow_version.py:
##########
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# 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 __future__ import annotations
+
+import re
+import sys
+from pathlib import Path
+
+import yaml
+
+try:
+ from yaml import CSafeLoader as SafeLoader
+except ImportError:
+ from yaml import SafeLoader # type: ignore
+
+ROOT_DIR = Path(__file__).resolve().parents[3]
+
+if __name__ == '__main__':
+ provider_files_pattern = Path(ROOT_DIR).glob("airflow/providers/**/provider.yaml")
+ all_provider_files = sorted(str(path) for path in provider_files_pattern)
+
+ if len(sys.argv) > 1:
+ paths = sorted(sys.argv[1:])
+ else:
+ paths = all_provider_files
+
+ for path in paths:
+ print(path)
+ with open(path) as yaml_file:
+ provider = yaml.load(yaml_file, SafeLoader)
+ deps = provider['dependencies']
+ try:
+ airflow_dep = [x for x in deps if x.startswith('apache-airflow>=')][0]
+ except IndexError:
+ continue
+ min_airflow_version = airflow_dep.split('>=')[1].split('.')
+ min_airflow_version = tuple(map(int, min_airflow_version))
Review Comment:
This is kind of fragile, using `packaging` to actually parse the line could be more reliable?
--
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
[GitHub] [airflow] potiuk commented on a diff in pull request #26793: Add MIN_AIRFLOW_VERSION constant to all providers
Posted by GitBox <gi...@apache.org>.
potiuk commented on code in PR #26793:
URL: https://github.com/apache/airflow/pull/26793#discussion_r984585172
##########
scripts/ci/pre_commit/pre_commit_check_provider_min_airflow_version.py:
##########
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# 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 __future__ import annotations
+
+import re
+import sys
+from pathlib import Path
+
+import yaml
+
+try:
+ from yaml import CSafeLoader as SafeLoader
+except ImportError:
+ from yaml import SafeLoader # type: ignore
+
+ROOT_DIR = Path(__file__).resolve().parents[3]
+
+if __name__ == '__main__':
+ provider_files_pattern = Path(ROOT_DIR).glob("airflow/providers/**/provider.yaml")
+ all_provider_files = sorted(str(path) for path in provider_files_pattern)
+
+ if len(sys.argv) > 1:
+ paths = sorted(sys.argv[1:])
+ else:
+ paths = all_provider_files
+
+ for path in paths:
+ print(path)
+ with open(path) as yaml_file:
+ provider = yaml.load(yaml_file, SafeLoader)
+ deps = provider['dependencies']
+ try:
+ airflow_dep = [x for x in deps if x.startswith('apache-airflow>=')][0]
+ except IndexError:
+ continue
+ min_airflow_version = airflow_dep.split('>=')[1].split('.')
+ min_airflow_version = tuple(map(int, min_airflow_version))
Review Comment:
Actually that's the only way. We cannot use packaging here. Using Packaging will not work because we do not have actual packages installed when we run the pre-commit. The pre-commit is run on sources and if we would like to use packaging, we would have to build all the provider packages and install them.
So we have to use provider.yaml wich is our "source of truth" for the provider packages.
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #26793: Add MIN_AIRFLOW_VERSION constant to all providers
Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #26793:
URL: https://github.com/apache/airflow/pull/26793#discussion_r984389892
##########
.pre-commit-config.yaml:
##########
@@ -363,6 +363,13 @@ repos:
files: ^airflow/providers/.*\.py$|^tests/providers/.*\.py$|^tests/system/providers/.*\.py$|^airflow/providers/.*/provider.yaml$
pass_filenames: false
additional_dependencies: ['setuptools', 'rich>=12.4.4', 'pyyaml']
+ - id: update-providers-min-airflow-version
+ name: Update min airflow version
+ entry: ./scripts/ci/pre_commit/pre_commit_build_providers_dependencies.py
+ language: python
+ files: ^airflow/providers/.*\.py$|^tests/providers/.*\.py$|^tests/system/providers/.*\.py$|^airflow/providers/.*/provider.yaml$
+ pass_filenames: false
+ additional_dependencies: ['setuptools', 'rich>=12.4.4', 'pyyaml']
Review Comment:
This looks like an unintended duplicate to the entry above it?
--
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