From 0bdd2c93d14ed4cb921b04e43191016953186b9f Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:01:19 -0500 Subject: [PATCH 01/33] switch to ibmcloudant dependency --- airflow/providers/cloudant/provider.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index 3f645d808ba92..e2ab481e11787 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -46,7 +46,7 @@ versions: dependencies: - apache-airflow>=2.8.0 - - cloudant>=2.13.0 + - ibmcloudant>=0.9.1 integrations: - integration-name: IBM Cloudant From 82da579c7aac47baac96c0ac1b915ac5be1d58d2 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:06:51 -0500 Subject: [PATCH 02/33] do not merge --- airflow/providers/cloudant/hooks/cloudant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index 41a2316ca89ba..b1cbba82f2b1d 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -21,7 +21,7 @@ from typing import Any -from cloudant import cloudant # type: ignore[attr-defined] +from cloudant import cloudant from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook From b9b9bc531a4557679bdc8e698f0874c5c90a6e42 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:16:54 -0500 Subject: [PATCH 03/33] updated provider deps --- generated/provider_dependencies.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated/provider_dependencies.json b/generated/provider_dependencies.json index a091b47d9d900..d3cf2812acb3b 100644 --- a/generated/provider_dependencies.json +++ b/generated/provider_dependencies.json @@ -352,7 +352,7 @@ "cloudant": { "deps": [ "apache-airflow>=2.8.0", - "cloudant>=2.13.0" + "ibmcloudant>=0.9.1" ], "devel-deps": [], "plugins": [], From 6eabb6017659edfa9a6a34dd0c602133a7a9d75f Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Sat, 17 Aug 2024 12:05:59 -0500 Subject: [PATCH 04/33] new code and tests --- airflow/providers/cloudant/hooks/cloudant.py | 20 +++++---- .../providers/cloudant/hooks/test_cloudant.py | 44 ++++++++++++++++--- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index b1cbba82f2b1d..7e358c8c1af2b 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -21,10 +21,11 @@ from typing import Any -from cloudant import cloudant +from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook +from airflow.models import Connection class CloudantHook(BaseHook): @@ -53,27 +54,30 @@ def __init__(self, cloudant_conn_id: str = default_conn_name) -> None: super().__init__() self.cloudant_conn_id = cloudant_conn_id - def get_conn(self) -> cloudant: + def get_conn(self) -> CloudantV1: """ Open a connection to the cloudant service and close it automatically if used as context manager. .. note:: In the connection form: - - 'host' equals the 'Account' (optional) + - 'host' equals the 'Account' (required) - 'login' equals the 'Username (or API Key)' (required) - 'password' equals the 'Password' (required) - :return: an authorized cloudant session context manager object. + :return: a CloudantV1 service object backed by a session-based user/password authenticator. """ conn = self.get_connection(self.cloudant_conn_id) self._validate_connection(conn) - cloudant_session = cloudant(user=conn.login, passwd=conn.password, account=conn.host) + authenticator = CouchDbSessionAuthenticator(username=conn.login, password=conn.password) + service = CloudantV1(authenticator=authenticator) + service.set_service_url(f"https://{conn.host}.cloudant.com") - return cloudant_session + return service - def _validate_connection(self, conn: cloudant) -> None: - for conn_param in ["login", "password"]: + @staticmethod + def _validate_connection(conn: Connection) -> None: + for conn_param in ["host", "login", "password"]: if not getattr(conn, conn_param): raise AirflowException(f"missing connection parameter {conn_param}") diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index 8e7d3cd9a760a..3be2e19b53359 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -34,20 +34,50 @@ def setup_method(self): @patch( "airflow.providers.cloudant.hooks.cloudant.CloudantHook.get_connection", - return_value=Connection(login="user", password="password", host="account"), + return_value=Connection(login="the_user", password="the_password", host="the_account"), ) - @patch("airflow.providers.cloudant.hooks.cloudant.cloudant") - def test_get_conn(self, mock_cloudant, mock_get_connection): + @patch("airflow.providers.cloudant.hooks.cloudant.CouchDbSessionAuthenticator") + @patch("airflow.providers.cloudant.hooks.cloudant.CloudantV1") + def test_get_conn_passes_expected_params_and_returns_cloudant_object( + self, mock_cloudant_v1, mock_session_authenticator, mock_get_connection + ): cloudant_session = self.cloudant_hook.get_conn() conn = mock_get_connection.return_value - mock_cloudant.assert_called_once_with(user=conn.login, passwd=conn.password, account=conn.host) - assert cloudant_session == mock_cloudant.return_value + + mock_session_authenticator.assert_called_once_with(username=conn.login, password=conn.password) + mock_cloudant_v1.assert_called_once_with(authenticator=mock_session_authenticator.return_value) + + cloudant_service = mock_cloudant_v1.return_value + cloudant_service.set_service_url.assert_called_once_with(f"https://{conn.host}.cloudant.com") + + assert cloudant_session == cloudant_service @patch( "airflow.providers.cloudant.hooks.cloudant.CloudantHook.get_connection", - return_value=Connection(login="user"), + return_value=Connection(login="user", password="password"), + ) + def test_get_conn_2(self, mock_get_connection): + cloudant_session = self.cloudant_hook.get_conn() + + conn = mock_get_connection.return_value + with cloudant_session as cs: + assert cs + + @pytest.mark.parametrize( + "conn", + [ + Connection(), + Connection(host="acct"), + Connection(login="user"), + Connection(password="pwd"), + Connection(host="acct", login="user"), + Connection(host="acct", password="pwd"), + Connection(login="user", password="pwd"), + ], ) - def test_get_conn_invalid_connection(self, mock_get_connection): + @patch("airflow.providers.cloudant.hooks.cloudant.CloudantHook.get_connection") + def test_get_conn_invalid_connection(self, mock_get_connection, conn): + mock_get_connection.return_value = conn with pytest.raises(AirflowException): self.cloudant_hook.get_conn() From a77cd5c8f6e2e5a7388f93eea9c0376f08df309b Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Sat, 17 Aug 2024 12:15:30 -0500 Subject: [PATCH 05/33] tweaks --- airflow/providers/cloudant/hooks/cloudant.py | 10 +++++++--- tests/providers/cloudant/hooks/test_cloudant.py | 12 ------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index 7e358c8c1af2b..fb7c5d3ab28d9 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -21,11 +21,10 @@ from typing import Any -from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator - from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook from airflow.models import Connection +from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator class CloudantHook(BaseHook): @@ -78,6 +77,11 @@ def get_conn(self) -> CloudantV1: @staticmethod def _validate_connection(conn: Connection) -> None: + missing_params = [] for conn_param in ["host", "login", "password"]: if not getattr(conn, conn_param): - raise AirflowException(f"missing connection parameter {conn_param}") + missing_params.append(conn_param) + + if missing_params: + raise AirflowException( + f"Missing connection parameter{'s' if len(missing_params) > 1 else ''}: {', '.join(missing_params)}") diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index 3be2e19b53359..776872058d5a1 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -20,7 +20,6 @@ from unittest.mock import patch import pytest - from airflow.exceptions import AirflowException from airflow.models import Connection from airflow.providers.cloudant.hooks.cloudant import CloudantHook @@ -53,17 +52,6 @@ def test_get_conn_passes_expected_params_and_returns_cloudant_object( assert cloudant_session == cloudant_service - @patch( - "airflow.providers.cloudant.hooks.cloudant.CloudantHook.get_connection", - return_value=Connection(login="user", password="password"), - ) - def test_get_conn_2(self, mock_get_connection): - cloudant_session = self.cloudant_hook.get_conn() - - conn = mock_get_connection.return_value - with cloudant_session as cs: - assert cs - @pytest.mark.parametrize( "conn", [ From 90cff2ae039ee4b238f3034c9024327c4dea0818 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Sat, 17 Aug 2024 12:18:54 -0500 Subject: [PATCH 06/33] more tweaks --- airflow/providers/cloudant/hooks/cloudant.py | 9 ++++++--- tests/providers/cloudant/hooks/test_cloudant.py | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index fb7c5d3ab28d9..9c20a9cc9dff1 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -19,12 +19,15 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any + +from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook -from airflow.models import Connection -from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator + +if TYPE_CHECKING: + from airflow.models import Connection class CloudantHook(BaseHook): diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index 776872058d5a1..e5c78b8d542df 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -20,6 +20,7 @@ from unittest.mock import patch import pytest + from airflow.exceptions import AirflowException from airflow.models import Connection from airflow.providers.cloudant.hooks.cloudant import CloudantHook From 54ec1a5fcc0a6296ed0543910f3512eec9d7d7f4 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Sat, 17 Aug 2024 14:12:58 -0500 Subject: [PATCH 07/33] adjust hidden fields --- airflow/providers/cloudant/hooks/cloudant.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index 9c20a9cc9dff1..a3f4e5f6cff29 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -48,8 +48,8 @@ class CloudantHook(BaseHook): def get_ui_field_behaviour(cls) -> dict[str, Any]: """Return custom field behaviour.""" return { - "hidden_fields": ["port", "extra"], - "relabeling": {"host": "Account", "login": "Username (or API Key)", "schema": "Database"}, + "hidden_fields": ["schema", "port", "extra"], + "relabeling": {"host": "Account", "login": "Username (or API Key)"}, } def __init__(self, cloudant_conn_id: str = default_conn_name) -> None: @@ -87,4 +87,5 @@ def _validate_connection(conn: Connection) -> None: if missing_params: raise AirflowException( - f"Missing connection parameter{'s' if len(missing_params) > 1 else ''}: {', '.join(missing_params)}") + f"Missing connection parameter{'s' if len(missing_params) > 1 else ''}: {', '.join(missing_params)}" + ) From 69cc490fb10d759553c10f542612a397f991e6c0 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Sun, 18 Aug 2024 21:03:08 -0500 Subject: [PATCH 08/33] add excluded-python-versions --- airflow/providers/cloudant/provider.yaml | 6 ++++++ generated/provider_dependencies.json | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index e2ab481e11787..b3afd994e544d 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -48,6 +48,12 @@ dependencies: - apache-airflow>=2.8.0 - ibmcloudant>=0.9.1 +excluded-python-versions: + # lorem ipsum TBD + # https://github.com/snowflakedb/snowflake-connector-python/issues/2016 + - "3.8" + - "3.9" + integrations: - integration-name: IBM Cloudant external-doc-url: https://www.ibm.com/cloud/cloudant diff --git a/generated/provider_dependencies.json b/generated/provider_dependencies.json index d3cf2812acb3b..7e158f476af4f 100644 --- a/generated/provider_dependencies.json +++ b/generated/provider_dependencies.json @@ -357,7 +357,10 @@ "devel-deps": [], "plugins": [], "cross-providers-deps": [], - "excluded-python-versions": [], + "excluded-python-versions": [ + "3.8", + "3.9" + ], "state": "ready" }, "cncf.kubernetes": { From f7b6d70f95566e39885f08f5354e79adc2c30213 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Mon, 19 Aug 2024 01:12:50 -0500 Subject: [PATCH 09/33] document --- airflow/providers/cloudant/provider.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index b3afd994e544d..bdf7f8cc9beaa 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -49,8 +49,10 @@ dependencies: - ibmcloudant>=0.9.1 excluded-python-versions: - # lorem ipsum TBD - # https://github.com/snowflakedb/snowflake-connector-python/issues/2016 + # ibmcloudant transitively brings in urllib3 2.x, but the snowflake provider has a dependency that pins + # urllib3 to 1.x on Python 3.8 and 3.9; thus we exclude those Python versions from taking the update + # to ibmcloudant. + # See #21004, #41555, and https://github.com/snowflakedb/snowflake-connector-python/issues/2016 - "3.8" - "3.9" From f948a19c022e14dcb0f390af8b71bec75ebec0a3 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:30:05 -0500 Subject: [PATCH 10/33] exclude Python 3.12 --- airflow/providers/cloudant/provider.yaml | 2 ++ generated/provider_dependencies.json | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index bdf7f8cc9beaa..53589f6f60567 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -55,6 +55,8 @@ excluded-python-versions: # See #21004, #41555, and https://github.com/snowflakedb/snowflake-connector-python/issues/2016 - "3.8" - "3.9" + # ibmcloudant brings in ibm-cloud-sdk-core which does not support Python 3.12 + - "3.12" integrations: - integration-name: IBM Cloudant diff --git a/generated/provider_dependencies.json b/generated/provider_dependencies.json index 7e158f476af4f..0cd4a639e44ef 100644 --- a/generated/provider_dependencies.json +++ b/generated/provider_dependencies.json @@ -359,7 +359,8 @@ "cross-providers-deps": [], "excluded-python-versions": [ "3.8", - "3.9" + "3.9", + "3.12" ], "state": "ready" }, From a67e13e64ed1f8e88be90c9cc99ccc748b01298c Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Mon, 19 Aug 2024 22:02:24 -0500 Subject: [PATCH 11/33] skip cloudant tests below Python 3.10 --- tests/providers/cloudant/hooks/test_cloudant.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index e5c78b8d542df..5d7334d33735e 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -17,15 +17,20 @@ # under the License. from __future__ import annotations +import sys from unittest.mock import patch import pytest from airflow.exceptions import AirflowException from airflow.models import Connection -from airflow.providers.cloudant.hooks.cloudant import CloudantHook -pytestmark = pytest.mark.db_test +pytestmark = [pytest.mark.db_test] + +if sys.version_info >= (3, 10): + from airflow.providers.cloudant.hooks.cloudant import CloudantHook +else: + pytestmark.append(pytest.mark.skip(f"bupkus {__name__}")) class TestCloudantHook: From fd1d6cd7292d055b69d576ea63aba2c6378ee8c7 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Mon, 19 Aug 2024 22:27:07 -0500 Subject: [PATCH 12/33] breaking change version --- airflow/providers/cloudant/provider.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index 53589f6f60567..e540465465f12 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -25,6 +25,7 @@ state: ready source-date-epoch: 1723969866 # note that those versions are maintained by release manager - do not update them manually versions: + - 4.0.0 - 3.6.0 - 3.5.2 - 3.5.1 From 297bacda02493284fcde42dfccd2b1f943505364 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Mon, 19 Aug 2024 22:59:13 -0500 Subject: [PATCH 13/33] changelog --- airflow/providers/cloudant/CHANGELOG.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/airflow/providers/cloudant/CHANGELOG.rst b/airflow/providers/cloudant/CHANGELOG.rst index ceb4d95ed6328..a32cd2b42f2ec 100644 --- a/airflow/providers/cloudant/CHANGELOG.rst +++ b/airflow/providers/cloudant/CHANGELOG.rst @@ -27,6 +27,14 @@ Changelog --------- +4.0.0 +..... + +Breaking changes +~~~~~~~~~~~~~~~~ + +* ``Switch cloudant provider from cloudant library to ibmcloudant library (#41555)`` + 3.6.0 ..... From ad7f68c999a970d432d86d21a48eb7be44a255c7 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:12:14 -0500 Subject: [PATCH 14/33] improve skip comment --- tests/providers/cloudant/hooks/test_cloudant.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index 5d7334d33735e..63ff140debeeb 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -30,7 +30,11 @@ if sys.version_info >= (3, 10): from airflow.providers.cloudant.hooks.cloudant import CloudantHook else: - pytestmark.append(pytest.mark.skip(f"bupkus {__name__}")) + pytestmark.append( + pytest.mark.skip( + f"Skipping {__name__} as the cloudant provider is not supported on Python 3.8, 3.9 and 3.12, see #41555." + ) + ) class TestCloudantHook: From 0a6eee15f2711ea130a7d093a618830f63217df2 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Tue, 20 Aug 2024 09:45:18 -0500 Subject: [PATCH 15/33] introduce hacky fake cloudant for <3.10 --- airflow/providers/cloudant/cloudant_fake.py | 22 ++++++++++++++++++++ airflow/providers/cloudant/hooks/cloudant.py | 6 +++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 airflow/providers/cloudant/cloudant_fake.py diff --git a/airflow/providers/cloudant/cloudant_fake.py b/airflow/providers/cloudant/cloudant_fake.py new file mode 100644 index 0000000000000..264bfb5d780df --- /dev/null +++ b/airflow/providers/cloudant/cloudant_fake.py @@ -0,0 +1,22 @@ +# 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 + +from unittest.mock import Mock + +CloudantV1 = Mock() +CouchDbSessionAuthenticator = Mock() diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index a3f4e5f6cff29..34459418e6f75 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -19,9 +19,13 @@ from __future__ import annotations +import sys from typing import TYPE_CHECKING, Any -from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator +if sys.version_info >= (3, 10): + from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator +else: + from airflow.providers.cloudant.cloudant_fake import CloudantV1, CouchDbSessionAuthenticator from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook From 95093c72326964205215a62df8da4201f269b2cf Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:45:40 -0500 Subject: [PATCH 16/33] docs --- airflow/providers/cloudant/hooks/cloudant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index 34459418e6f75..623b0b5fdc2d8 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -62,7 +62,7 @@ def __init__(self, cloudant_conn_id: str = default_conn_name) -> None: def get_conn(self) -> CloudantV1: """ - Open a connection to the cloudant service and close it automatically if used as context manager. + Create an authenticated service object for connection to the Cloudant service. .. note:: In the connection form: From 9cf1d6997bf1b7354d575abbad7603216d078082 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:46:02 -0500 Subject: [PATCH 17/33] docs --- docs/spelling_wordlist.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 46b441ef3e3f6..ecbfafc33d34a 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -250,7 +250,7 @@ classpaths cleartext cli clientId -Cloudant +CloudantV cloudant cloudbuild CloudBuildClient @@ -775,6 +775,7 @@ hyperparameter hyperparameters IaC iam +ibmcloudant idempotence idempotency IdP From 4aea0082ddc840f87937b2088db62d70a8b4a523 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:20:47 -0500 Subject: [PATCH 18/33] spelling sort --- docs/spelling_wordlist.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index ecbfafc33d34a..2556113d001dc 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -250,8 +250,8 @@ classpaths cleartext cli clientId -CloudantV cloudant +CloudantV cloudbuild CloudBuildClient cloudml From feba1112d6f0b93206483c2a00b69224b72e8d3e Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:59:44 -0500 Subject: [PATCH 19/33] type shenanigans --- airflow/providers/cloudant/cloudant_fake.py | 18 +++++++++++++++--- airflow/providers/cloudant/provider.yaml | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/airflow/providers/cloudant/cloudant_fake.py b/airflow/providers/cloudant/cloudant_fake.py index 264bfb5d780df..91b97c72a91c8 100644 --- a/airflow/providers/cloudant/cloudant_fake.py +++ b/airflow/providers/cloudant/cloudant_fake.py @@ -16,7 +16,19 @@ # under the License. from __future__ import annotations -from unittest.mock import Mock -CloudantV1 = Mock() -CouchDbSessionAuthenticator = Mock() +class CloudantV1: + """Phony class to pass mypy when real class is not imported.""" + + def __init__(self, authenticator): + pass + + def set_service_url(self, service_url: str): + pass + + +class CouchDbSessionAuthenticator: + """Phony class to pass mypy when real class is not imported.""" + + def __init__(self, username: str, password: str): + pass diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index e540465465f12..893767799d756 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -56,7 +56,8 @@ excluded-python-versions: # See #21004, #41555, and https://github.com/snowflakedb/snowflake-connector-python/issues/2016 - "3.8" - "3.9" - # ibmcloudant brings in ibm-cloud-sdk-core which does not support Python 3.12 + # ibmcloudant brings in ibm-cloud-sdk-core which does not yet support Python 3.12; this should + # be fixed in ibmcloudant's next release - "3.12" integrations: From 918bee4106ece1def6dcb4e761cf410eba88fa38 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:20:55 -0500 Subject: [PATCH 20/33] release version overwrite? --- airflow/providers/cloudant/CHANGELOG.rst | 3 +++ airflow/providers/cloudant/__init__.py | 2 +- airflow/providers/cloudant/provider.yaml | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/airflow/providers/cloudant/CHANGELOG.rst b/airflow/providers/cloudant/CHANGELOG.rst index a32cd2b42f2ec..df9aff3e96593 100644 --- a/airflow/providers/cloudant/CHANGELOG.rst +++ b/airflow/providers/cloudant/CHANGELOG.rst @@ -35,6 +35,9 @@ Breaking changes * ``Switch cloudant provider from cloudant library to ibmcloudant library (#41555)`` +.. Review and move the new changes to one of the sections above: + * ``Prepare docs for Aug 2nd wave of providers (#41559)`` + 3.6.0 ..... diff --git a/airflow/providers/cloudant/__init__.py b/airflow/providers/cloudant/__init__.py index 586634cbc8075..05483dfd46169 100644 --- a/airflow/providers/cloudant/__init__.py +++ b/airflow/providers/cloudant/__init__.py @@ -29,7 +29,7 @@ __all__ = ["__version__"] -__version__ = "3.6.0" +__version__ = "4.0.0" if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse( "2.8.0" diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index 893767799d756..b20a30fef08c4 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -26,7 +26,6 @@ source-date-epoch: 1723969866 # note that those versions are maintained by release manager - do not update them manually versions: - 4.0.0 - - 3.6.0 - 3.5.2 - 3.5.1 - 3.5.0 From 9551ebeab9b2b3cd7baa3492a67216f9e1ec58c4 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:22:19 -0500 Subject: [PATCH 21/33] release version overwrite? redux --- airflow/providers/cloudant/CHANGELOG.rst | 3 --- airflow/providers/cloudant/__init__.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/airflow/providers/cloudant/CHANGELOG.rst b/airflow/providers/cloudant/CHANGELOG.rst index df9aff3e96593..a32cd2b42f2ec 100644 --- a/airflow/providers/cloudant/CHANGELOG.rst +++ b/airflow/providers/cloudant/CHANGELOG.rst @@ -35,9 +35,6 @@ Breaking changes * ``Switch cloudant provider from cloudant library to ibmcloudant library (#41555)`` -.. Review and move the new changes to one of the sections above: - * ``Prepare docs for Aug 2nd wave of providers (#41559)`` - 3.6.0 ..... diff --git a/airflow/providers/cloudant/__init__.py b/airflow/providers/cloudant/__init__.py index 05483dfd46169..586634cbc8075 100644 --- a/airflow/providers/cloudant/__init__.py +++ b/airflow/providers/cloudant/__init__.py @@ -29,7 +29,7 @@ __all__ = ["__version__"] -__version__ = "4.0.0" +__version__ = "3.6.0" if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse( "2.8.0" From 577aa550c7dff295490cf24151968d3dce0bcc9d Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Wed, 21 Aug 2024 00:18:56 -0500 Subject: [PATCH 22/33] test exemption --- tests/always/test_project_structure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/always/test_project_structure.py b/tests/always/test_project_structure.py index ae59f12ffcb1b..cf87efebe3238 100644 --- a/tests/always/test_project_structure.py +++ b/tests/always/test_project_structure.py @@ -85,6 +85,7 @@ def test_providers_modules_should_have_tests(self): "tests/providers/apache/hive/plugins/test_hive.py", "tests/providers/celery/executors/test_celery_executor_utils.py", "tests/providers/celery/executors/test_default_celery.py", + "tests/providers/cloudant/test_cloudant_fake.py", "tests/providers/cncf/kubernetes/backcompat/test_backwards_compat_converters.py", "tests/providers/cncf/kubernetes/executors/test_kubernetes_executor_types.py", "tests/providers/cncf/kubernetes/executors/test_kubernetes_executor_utils.py", From 161ceeb34c53997c1e32ef691ec387b038e3d217 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:36:32 -0500 Subject: [PATCH 23/33] exclude Python 3.12 in Cloudant class and tests --- airflow/providers/cloudant/hooks/cloudant.py | 2 +- tests/providers/cloudant/hooks/test_cloudant.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index 623b0b5fdc2d8..96ba9bd6c42d1 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -22,7 +22,7 @@ import sys from typing import TYPE_CHECKING, Any -if sys.version_info >= (3, 10): +if (3, 10) <= sys.version_info < (3, 12): from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator else: from airflow.providers.cloudant.cloudant_fake import CloudantV1, CouchDbSessionAuthenticator diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index 63ff140debeeb..7a0cf5bf65f1b 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -27,7 +27,7 @@ pytestmark = [pytest.mark.db_test] -if sys.version_info >= (3, 10): +if (3, 10) <= sys.version_info < (3, 12): from airflow.providers.cloudant.hooks.cloudant import CloudantHook else: pytestmark.append( From 057cb59a76fcf620bc44cbd9949b6d6c4563db2a Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Sun, 25 Aug 2024 23:00:56 -0500 Subject: [PATCH 24/33] try providers checks without cloudant provider --- .github/workflows/check-providers.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/check-providers.yml b/.github/workflows/check-providers.yml index e89d4a81faaca..b394f7927329a 100644 --- a/.github/workflows/check-providers.yml +++ b/.github/workflows/check-providers.yml @@ -108,6 +108,11 @@ jobs: run: > breeze release-management generate-issue-content-providers --only-available-in-dist --disable-progress + - name: > + Remove incompatible Python ${{ matrix.python-version }} provider packages + run: | + echo "Removing Python 3.8-incompatible provider: cloudant" + rm -vf dist/apache_airflow_providers_cloudant* - name: "Generate source constraints from CI image" shell: bash run: > From 0c9c4bc08fa93e239c1c7d603e7570a60450a9fd Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Sun, 25 Aug 2024 23:29:17 -0500 Subject: [PATCH 25/33] add cloudant to remove-providers options --- dev/breeze/src/airflow_breeze/global_constants.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/breeze/src/airflow_breeze/global_constants.py b/dev/breeze/src/airflow_breeze/global_constants.py index 6f6545bf8f67d..ab191e4f1b36d 100644 --- a/dev/breeze/src/airflow_breeze/global_constants.py +++ b/dev/breeze/src/airflow_breeze/global_constants.py @@ -509,19 +509,19 @@ def get_airflow_extras(): { "python-version": "3.8", "airflow-version": "2.8.4", - "remove-providers": "fab", + "remove-providers": "cloudant fab", "run-tests": "true", }, { "python-version": "3.8", "airflow-version": "2.9.3", - "remove-providers": "", + "remove-providers": "cloudant", "run-tests": "true", }, { "python-version": "3.8", "airflow-version": "2.10.0", - "remove-providers": "", + "remove-providers": "cloudant", "run-tests": "true", }, ] From bbe4431e5aee69f70562a804026bd534d2d04639 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Thu, 29 Aug 2024 22:59:21 +0200 Subject: [PATCH 26/33] fix provider version --- airflow/providers/cloudant/provider.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index b20a30fef08c4..893767799d756 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -26,6 +26,7 @@ source-date-epoch: 1723969866 # note that those versions are maintained by release manager - do not update them manually versions: - 4.0.0 + - 3.6.0 - 3.5.2 - 3.5.1 - 3.5.0 From 2c5b4b62c313a35c06a9d68445da8920d0a53854 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Thu, 29 Aug 2024 23:13:43 +0200 Subject: [PATCH 27/33] try with 3.12 --- airflow/providers/cloudant/provider.yaml | 3 --- generated/provider_dependencies.json | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/airflow/providers/cloudant/provider.yaml b/airflow/providers/cloudant/provider.yaml index 893767799d756..09857936b877b 100644 --- a/airflow/providers/cloudant/provider.yaml +++ b/airflow/providers/cloudant/provider.yaml @@ -56,9 +56,6 @@ excluded-python-versions: # See #21004, #41555, and https://github.com/snowflakedb/snowflake-connector-python/issues/2016 - "3.8" - "3.9" - # ibmcloudant brings in ibm-cloud-sdk-core which does not yet support Python 3.12; this should - # be fixed in ibmcloudant's next release - - "3.12" integrations: - integration-name: IBM Cloudant diff --git a/generated/provider_dependencies.json b/generated/provider_dependencies.json index 0cd4a639e44ef..7e158f476af4f 100644 --- a/generated/provider_dependencies.json +++ b/generated/provider_dependencies.json @@ -359,8 +359,7 @@ "cross-providers-deps": [], "excluded-python-versions": [ "3.8", - "3.9", - "3.12" + "3.9" ], "state": "ready" }, From 9bd3c19e14803c673f13a4d2fb22c1677eb92319 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:45:24 +0200 Subject: [PATCH 28/33] REVERT BEFORE MERGE more logging in lowest dependency tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14fe0bbe4baa9..90f9f3b61f7d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -521,7 +521,7 @@ jobs: excluded-providers-as-string: ${{ needs.build-info.outputs.excluded-providers-as-string }} excludes: "[]" parallel-test-types-list-as-string: ${{ needs.build-info.outputs.separate-test-types-list-as-string }} - include-success-outputs: ${{ needs.build-info.outputs.include-success-outputs }} + include-success-outputs: "true" run-coverage: ${{ needs.build-info.outputs.run-coverage }} debug-resources: ${{ needs.build-info.outputs.debug-resources }} monitor-delay-time-in-seconds: 120 From b91d7c48788fc7de885e691ec5e4ea0481211ce4 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Sun, 1 Sep 2024 01:56:31 +0200 Subject: [PATCH 29/33] fixup! REVERT BEFORE MERGE more logging in lowest dependency tests --- Dockerfile.ci | 7 +++++++ scripts/docker/entrypoint_ci.sh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Dockerfile.ci b/Dockerfile.ci index 9d9de62dd1a4b..cc9ba9eb03e2b 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -1063,6 +1063,13 @@ function check_run_tests() { return fi + if [[ " 3.8 3.9 3.12 " == *" ${PYTHON_MAJOR_MINOR_VERSION} "* && ${TEST_TYPE} == "Providers[cloudant]" ]]; then + echo + echo "${COLOR_YELLOW}Skipping Cloudant tests on Python 3.8, 3.9, 3.12 because cloudant is disabled there${COLOR_RESET}" + echo + exit 0 + fi + if [[ ${REMOVE_ARM_PACKAGES:="false"} == "true" ]]; then # Test what happens if we do not have ARM packages installed. # This is useful to see if pytest collection works without ARM packages which is important diff --git a/scripts/docker/entrypoint_ci.sh b/scripts/docker/entrypoint_ci.sh index 534171355f2e9..07060eaad0b21 100755 --- a/scripts/docker/entrypoint_ci.sh +++ b/scripts/docker/entrypoint_ci.sh @@ -303,6 +303,13 @@ function check_run_tests() { return fi + if [[ " 3.8 3.9 3.12 " == *" ${PYTHON_MAJOR_MINOR_VERSION} "* && ${TEST_TYPE} == "Providers[cloudant]" ]]; then + echo + echo "${COLOR_YELLOW}Skipping Cloudant tests on Python 3.8, 3.9, 3.12 because cloudant is disabled there${COLOR_RESET}" + echo + exit 0 + fi + if [[ ${REMOVE_ARM_PACKAGES:="false"} == "true" ]]; then # Test what happens if we do not have ARM packages installed. # This is useful to see if pytest collection works without ARM packages which is important From 7b38c76f162165740aa37ff75844b5d5e7196c16 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:34:12 +0200 Subject: [PATCH 30/33] Revert "REVERT BEFORE MERGE more logging in lowest dependency tests" This reverts commit d36061119e05b1292cadfdc14090ec33130d1552. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90f9f3b61f7d4..14fe0bbe4baa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -521,7 +521,7 @@ jobs: excluded-providers-as-string: ${{ needs.build-info.outputs.excluded-providers-as-string }} excludes: "[]" parallel-test-types-list-as-string: ${{ needs.build-info.outputs.separate-test-types-list-as-string }} - include-success-outputs: "true" + include-success-outputs: ${{ needs.build-info.outputs.include-success-outputs }} run-coverage: ${{ needs.build-info.outputs.run-coverage }} debug-resources: ${{ needs.build-info.outputs.debug-resources }} monitor-delay-time-in-seconds: 120 From 5b20afa44e0d5504ae51809a2c3697c741be8dfa Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Thu, 5 Sep 2024 03:42:31 +0200 Subject: [PATCH 31/33] fix selective checks excluded providers test --- dev/breeze/src/airflow_breeze/utils/selective_checks.py | 6 ++++-- dev/breeze/tests/test_selective_checks.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dev/breeze/src/airflow_breeze/utils/selective_checks.py b/dev/breeze/src/airflow_breeze/utils/selective_checks.py index d432d8fb207f9..eb38675fb3aab 100644 --- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py +++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py @@ -81,7 +81,6 @@ USE_PUBLIC_RUNNERS_LABEL = "use public runners" USE_SELF_HOSTED_RUNNERS_LABEL = "use self-hosted runners" - ALL_CI_SELECTIVE_TEST_TYPES = ( "API Always BranchExternalPython BranchPythonVenv " "CLI Core ExternalPython Operators Other PlainAsserts " @@ -1278,7 +1277,10 @@ def excluded_providers_as_string(self) -> str: if "excluded-python-versions" in provider_info: for python_version in provider_info["excluded-python-versions"]: providers_to_exclude[python_version].append(provider) - return json.dumps(providers_to_exclude) + sorted_providers_to_exclude = dict( + sorted(providers_to_exclude.items(), key=lambda item: int(item[0].split(".")[1])) + ) # ^ sort by Python minor version + return json.dumps(sorted_providers_to_exclude) @cached_property def testable_integrations(self) -> list[str]: diff --git a/dev/breeze/tests/test_selective_checks.py b/dev/breeze/tests/test_selective_checks.py index 9e4476425207d..2491b6f920cf8 100644 --- a/dev/breeze/tests/test_selective_checks.py +++ b/dev/breeze/tests/test_selective_checks.py @@ -853,7 +853,9 @@ def test_excluded_providers(): ) assert_outputs_are_printed( { - "excluded-providers-as-string": json.dumps({"3.12": ["apache.beam"]}), + "excluded-providers-as-string": json.dumps( + {"3.8": ["cloudant"], "3.9": ["cloudant"], "3.12": ["apache.beam"]} + ), }, str(stderr), ) From 69ded9b28282083c498ec8cb3abaecc9d802a416 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:16:00 +0200 Subject: [PATCH 32/33] re-enable 3.12 and remove CI changes --- Dockerfile.ci | 7 ------- scripts/docker/entrypoint_ci.sh | 7 ------- tests/providers/cloudant/hooks/test_cloudant.py | 2 +- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/Dockerfile.ci b/Dockerfile.ci index cc9ba9eb03e2b..9d9de62dd1a4b 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -1063,13 +1063,6 @@ function check_run_tests() { return fi - if [[ " 3.8 3.9 3.12 " == *" ${PYTHON_MAJOR_MINOR_VERSION} "* && ${TEST_TYPE} == "Providers[cloudant]" ]]; then - echo - echo "${COLOR_YELLOW}Skipping Cloudant tests on Python 3.8, 3.9, 3.12 because cloudant is disabled there${COLOR_RESET}" - echo - exit 0 - fi - if [[ ${REMOVE_ARM_PACKAGES:="false"} == "true" ]]; then # Test what happens if we do not have ARM packages installed. # This is useful to see if pytest collection works without ARM packages which is important diff --git a/scripts/docker/entrypoint_ci.sh b/scripts/docker/entrypoint_ci.sh index 07060eaad0b21..534171355f2e9 100755 --- a/scripts/docker/entrypoint_ci.sh +++ b/scripts/docker/entrypoint_ci.sh @@ -303,13 +303,6 @@ function check_run_tests() { return fi - if [[ " 3.8 3.9 3.12 " == *" ${PYTHON_MAJOR_MINOR_VERSION} "* && ${TEST_TYPE} == "Providers[cloudant]" ]]; then - echo - echo "${COLOR_YELLOW}Skipping Cloudant tests on Python 3.8, 3.9, 3.12 because cloudant is disabled there${COLOR_RESET}" - echo - exit 0 - fi - if [[ ${REMOVE_ARM_PACKAGES:="false"} == "true" ]]; then # Test what happens if we do not have ARM packages installed. # This is useful to see if pytest collection works without ARM packages which is important diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index 7a0cf5bf65f1b..68b1c284cbd51 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -32,7 +32,7 @@ else: pytestmark.append( pytest.mark.skip( - f"Skipping {__name__} as the cloudant provider is not supported on Python 3.8, 3.9 and 3.12, see #41555." + f"Skipping {__name__} as the cloudant provider is not supported on Python 3.8 and 3.9, see #41555." ) ) From 16f27a66c7a8d18161c92348b8969f05fb69b328 Mon Sep 17 00:00:00 2001 From: "Christopher P. Anderson" <48180628+topherinternational@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:32:25 +0200 Subject: [PATCH 33/33] redux 3.12 --- airflow/providers/cloudant/hooks/cloudant.py | 6 +++--- tests/providers/cloudant/hooks/test_cloudant.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/airflow/providers/cloudant/hooks/cloudant.py b/airflow/providers/cloudant/hooks/cloudant.py index 96ba9bd6c42d1..b09ad6932efa6 100644 --- a/airflow/providers/cloudant/hooks/cloudant.py +++ b/airflow/providers/cloudant/hooks/cloudant.py @@ -22,10 +22,10 @@ import sys from typing import TYPE_CHECKING, Any -if (3, 10) <= sys.version_info < (3, 12): - from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator -else: +if sys.version_info < (3, 10): from airflow.providers.cloudant.cloudant_fake import CloudantV1, CouchDbSessionAuthenticator +else: + from ibmcloudant import CloudantV1, CouchDbSessionAuthenticator from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index 68b1c284cbd51..eec71f65e79b3 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -27,14 +27,14 @@ pytestmark = [pytest.mark.db_test] -if (3, 10) <= sys.version_info < (3, 12): - from airflow.providers.cloudant.hooks.cloudant import CloudantHook -else: +if sys.version_info < (3, 10): pytestmark.append( pytest.mark.skip( f"Skipping {__name__} as the cloudant provider is not supported on Python 3.8 and 3.9, see #41555." ) ) +else: + from airflow.providers.cloudant.hooks.cloudant import CloudantHook class TestCloudantHook: