From 2455a42801d0d848ef0eb048fa437a6557dcb5bf Mon Sep 17 00:00:00 2001 From: btkcodedev Date: Thu, 27 Jun 2024 13:45:06 +0530 Subject: [PATCH 1/2] Replace deprecated AirbyteLogger with logging.Logger - source-bing-ads --- airbyte-integrations/connectors/source-bing-ads/metadata.yaml | 2 +- .../connectors/source-bing-ads/pyproject.toml | 2 +- .../connectors/source-bing-ads/source_bing_ads/client.py | 4 ++-- .../connectors/source-bing-ads/source_bing_ads/source.py | 4 ++-- docs/integrations/sources/bing-ads.md | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/airbyte-integrations/connectors/source-bing-ads/metadata.yaml b/airbyte-integrations/connectors/source-bing-ads/metadata.yaml index cfa3d143ab06..c1d34bef9081 100644 --- a/airbyte-integrations/connectors/source-bing-ads/metadata.yaml +++ b/airbyte-integrations/connectors/source-bing-ads/metadata.yaml @@ -16,7 +16,7 @@ data: connectorSubtype: api connectorType: source definitionId: 47f25999-dd5e-4636-8c39-e7cea2453331 - dockerImageTag: 2.6.4 + dockerImageTag: 2.6.5 dockerRepository: airbyte/source-bing-ads documentationUrl: https://docs.airbyte.com/integrations/sources/bing-ads githubIssueLabel: source-bing-ads diff --git a/airbyte-integrations/connectors/source-bing-ads/pyproject.toml b/airbyte-integrations/connectors/source-bing-ads/pyproject.toml index 8e7c68c142c6..9a644887d602 100644 --- a/airbyte-integrations/connectors/source-bing-ads/pyproject.toml +++ b/airbyte-integrations/connectors/source-bing-ads/pyproject.toml @@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",] build-backend = "poetry.core.masonry.api" [tool.poetry] -version = "2.6.4" +version = "2.6.5" name = "source-bing-ads" description = "Source implementation for Bing Ads." authors = [ "Airbyte ",] diff --git a/airbyte-integrations/connectors/source-bing-ads/source_bing_ads/client.py b/airbyte-integrations/connectors/source-bing-ads/source_bing_ads/client.py index afd7862a93f9..06c1c801917c 100644 --- a/airbyte-integrations/connectors/source-bing-ads/source_bing_ads/client.py +++ b/airbyte-integrations/connectors/source-bing-ads/source_bing_ads/client.py @@ -1,6 +1,7 @@ # # Copyright (c) 2023 Airbyte, Inc., all rights reserved. # +import logging import os import socket import ssl @@ -13,7 +14,6 @@ import backoff import pendulum -from airbyte_cdk.logger import AirbyteLogger from airbyte_cdk.models import FailureType from airbyte_cdk.utils import AirbyteTracedException from bingads.authorization import AuthorizationData, OAuthTokens, OAuthWebAuthCodeGrant @@ -32,7 +32,7 @@ class Client: api_version: int = 13 refresh_token_safe_delta: int = 10 # in seconds - logger: AirbyteLogger = AirbyteLogger() + logger: logging.Logger = logging.getLogger("airbyte") # retry on: rate limit errors, auth token expiration, internal errors # https://docs.microsoft.com/en-us/advertising/guides/services-protocol?view=bingads-13#throttling # https://docs.microsoft.com/en-us/advertising/guides/operation-error-codes?view=bingads-13 diff --git a/airbyte-integrations/connectors/source-bing-ads/source_bing_ads/source.py b/airbyte-integrations/connectors/source-bing-ads/source_bing_ads/source.py index 78cfe0a24d58..cb9253b902fb 100644 --- a/airbyte-integrations/connectors/source-bing-ads/source_bing_ads/source.py +++ b/airbyte-integrations/connectors/source-bing-ads/source_bing_ads/source.py @@ -1,10 +1,10 @@ # # Copyright (c) 2023 Airbyte, Inc., all rights reserved. # +import logging from itertools import product from typing import Any, List, Mapping, Optional, Tuple -from airbyte_cdk import AirbyteLogger from airbyte_cdk.models import FailureType, SyncMode from airbyte_cdk.sources import AbstractSource from airbyte_cdk.sources.streams import Stream @@ -97,7 +97,7 @@ class SourceBingAds(AbstractSource): Source implementation of Bing Ads API. Fetches advertising data from accounts """ - def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, Any]: + def check_connection(self, logger: logging.Logger, config: Mapping[str, Any]) -> Tuple[bool, Any]: try: client = Client(**config) accounts = Accounts(client, config) diff --git a/docs/integrations/sources/bing-ads.md b/docs/integrations/sources/bing-ads.md index f1ab188b0263..280e99de75ae 100644 --- a/docs/integrations/sources/bing-ads.md +++ b/docs/integrations/sources/bing-ads.md @@ -258,6 +258,7 @@ The Bing Ads API limits the number of requests for all Microsoft Advertising cli | Version | Date | Pull Request | Subject | | :------ | :--------- | :------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------- | +| 2.6.5 | 2024-06-27 | [40585](https://github.com/airbytehq/airbyte/pull/40585) | Replaced deprecated AirbyteLogger with logging.Logger | | 2.6.4 | 2024-06-25 | [40457](https://github.com/airbytehq/airbyte/pull/40457) | Update dependencies | | 2.6.3 | 2024-06-22 | [40006](https://github.com/airbytehq/airbyte/pull/40006) | Update dependencies | | 2.6.2 | 2024-06-06 | [39177](https://github.com/airbytehq/airbyte/pull/39177) | [autopull] Upgrade base image to v1.2.2 | From ab03633b9f9fe8b1ff982194c024ad6c91610e4c Mon Sep 17 00:00:00 2001 From: Dhroov Makwana Date: Fri, 28 Jun 2024 11:25:30 +0530 Subject: [PATCH 2/2] Replace AirbyteLogger, fix unit test assertion for logged info for empty csv file tests --- .../connectors/source-bing-ads/unit_tests/conftest.py | 2 +- .../integrations/test_app_install_ad_labels_stream.py | 2 +- .../unit_tests/integrations/test_app_install_ads_stream.py | 2 +- .../unit_tests/integrations/test_budget_stream.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/airbyte-integrations/connectors/source-bing-ads/unit_tests/conftest.py b/airbyte-integrations/connectors/source-bing-ads/unit_tests/conftest.py index 4eb197298b2d..edd2e8bca963 100644 --- a/airbyte-integrations/connectors/source-bing-ads/unit_tests/conftest.py +++ b/airbyte-integrations/connectors/source-bing-ads/unit_tests/conftest.py @@ -85,4 +85,4 @@ def config_with_custom_reports_fixture(): @pytest.fixture(name="logger_mock") def logger_mock_fixture(): - return patch("source_bing_ads.source.AirbyteLogger") + return patch("source_bing_ads.source.logging.Logger") diff --git a/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_app_install_ad_labels_stream.py b/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_app_install_ad_labels_stream.py index 025773e4a35c..ad9d5e5d3f89 100644 --- a/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_app_install_ad_labels_stream.py +++ b/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_app_install_ad_labels_stream.py @@ -22,7 +22,7 @@ def test_return_logged_info_for_empty_csv_file(self, http_mocker: HttpMocker): self.auth_client(http_mocker) output, _ = self.read_stream(self.stream_name, SyncMode.full_refresh, self._config, "app_install_ad_labels_empty") assert len(output.records) == 0 - assert len(output.logs) == 10 + assert len(output.logs) == 11 @HttpMocker() def test_transform_records(self, http_mocker: HttpMocker): diff --git a/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_app_install_ads_stream.py b/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_app_install_ads_stream.py index 831428bf11d9..2fc5eb22bf41 100644 --- a/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_app_install_ads_stream.py +++ b/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_app_install_ads_stream.py @@ -22,7 +22,7 @@ def test_return_logged_info_for_empty_csv_file(self, http_mocker: HttpMocker): self.auth_client(http_mocker) output, _ = self.read_stream(self.stream_name, SyncMode.full_refresh, self._config, "app_install_ads_empty") assert len(output.records) == 0 - assert len(output.logs) == 10 + assert len(output.logs) == 11 @HttpMocker() def test_transform_records(self, http_mocker: HttpMocker): diff --git a/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_budget_stream.py b/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_budget_stream.py index 5c6aebdd00a8..eb07625e3586 100644 --- a/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_budget_stream.py +++ b/airbyte-integrations/connectors/source-bing-ads/unit_tests/integrations/test_budget_stream.py @@ -22,7 +22,7 @@ def test_return_logged_info_for_empty_csv_file(self, http_mocker: HttpMocker): self.auth_client(http_mocker) output, _ = self.read_stream(self.stream_name, SyncMode.full_refresh, self._config, "budget_empty") assert len(output.records) == 0 - assert len(output.logs) == 10 + assert len(output.logs) == 11 @HttpMocker() def test_transform_records(self, http_mocker: HttpMocker):