Skip to content

Commit

Permalink
refactor(source-shopify): Replace AirbyteLogger with logging.Logger (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
girarda authored May 22, 2024
1 parent 833ac28 commit fa2cf11
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 9da77001-af33-4bcd-be46-6252bf9342b9
dockerImageTag: 2.1.0
dockerImageTag: 2.1.1
dockerRepository: airbyte/source-shopify
documentationUrl: https://docs.airbyte.com/integrations/sources/shopify
githubIssueLabel: source-shopify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
version = "2.1.0"
version = "2.1.1"
name = "source-shopify"
description = "Source CDK implementation for Shopify."
authors = [ "Airbyte <[email protected]>",]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import pendulum as pdm
import requests
from airbyte_cdk import AirbyteLogger
from requests.exceptions import JSONDecodeError
from source_shopify.utils import ApiTypeEnum
from source_shopify.utils import ShopifyRateLimiter as limiter
Expand All @@ -29,7 +28,7 @@ class ShopifyBulkManager:
stream_name: str

# default logger
logger: Final[AirbyteLogger] = logging.getLogger("airbyte")
logger: Final[logging.Logger] = logging.getLogger("airbyte")

# 10Mb chunk size to save the file
_retrieve_chunk_size: Final[int] = 1024 * 1024 * 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from os import remove
from typing import Any, Callable, Final, Iterable, List, Mapping, MutableMapping, Optional, Union

from airbyte_cdk import AirbyteLogger

from .exceptions import ShopifyBulkExceptions
from .query import ShopifyBulkQuery
from .tools import END_OF_FILE, BulkTools
Expand All @@ -25,7 +23,7 @@ class ShopifyBulkRecord:
buffer: List[MutableMapping[str, Any]] = field(init=False, default_factory=list)

# default logger
logger: Final[AirbyteLogger] = logging.getLogger("airbyte")
logger: Final[logging.Logger] = logging.getLogger("airbyte")

def __post_init__(self) -> None:
self.composition: Optional[Mapping[str, Any]] = self.query.record_composition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.

import logging
from functools import wraps
from time import sleep
from typing import Any, Callable, Final, Optional, Tuple, Type

from airbyte_cdk import AirbyteLogger

from .exceptions import ShopifyBulkExceptions

BULK_RETRY_ERRORS: Final[Tuple] = (
Expand All @@ -14,7 +13,7 @@
)


def bulk_retry_on_exception(logger: AirbyteLogger, more_exceptions: Optional[Tuple[Type[Exception], ...]] = None) -> Callable:
def bulk_retry_on_exception(logger: logging.Logger, more_exceptions: Optional[Tuple[Type[Exception], ...]] = None) -> Callable:
"""
A decorator to retry a function when specified exceptions are raised.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#


import logging
from typing import Any, List, Mapping, 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
Expand Down Expand Up @@ -143,7 +143,7 @@ def get_shop_name(config) -> str:
def format_stream_name(name) -> str:
return "".join(x.capitalize() for x in name.split("_"))

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]:
"""
Testing connection availability for the connector.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#

import logging
import os
from json import dumps
from typing import Any, List, Mapping

import pytest
import requests
from airbyte_cdk import AirbyteLogger
from airbyte_cdk.models import AirbyteStream, ConfiguredAirbyteCatalog, ConfiguredAirbyteStream, DestinationSyncMode, SyncMode

os.environ["REQUEST_CACHE_PATH"] = "REQUEST_CACHE_PATH"
Expand All @@ -25,7 +25,7 @@ def records_per_slice(parent_records: List[Mapping[str, Any]], state_checkpoint_

@pytest.fixture
def logger():
return AirbyteLogger()
return logging.getLogger("airbyte")


@pytest.fixture
Expand Down
85 changes: 43 additions & 42 deletions docs/integrations/sources/shopify.md

Large diffs are not rendered by default.

0 comments on commit fa2cf11

Please sign in to comment.