Skip to content

Commit

Permalink
Replace deprecated AirbyteLogger with logging.Logger - source-bing-ads (
Browse files Browse the repository at this point in the history
#40585)

Co-authored-by: Dhroov Makwana <pabloescoder@gmail.com>
btkcodedev and pabloescoder authored Jun 28, 2024
1 parent e7843c7 commit e9e5c1e
Showing 9 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 <contact@airbyte.io>",]
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
@@ -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):
Original file line number Diff line number Diff line change
@@ -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):
Original file line number Diff line number Diff line change
@@ -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):
1 change: 1 addition & 0 deletions docs/integrations/sources/bing-ads.md
Original file line number Diff line number Diff line change
@@ -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 |

0 comments on commit e9e5c1e

Please sign in to comment.