Skip to content

Commit

Permalink
🐛 Airbyte CDK: fixing integration test failing
Browse files Browse the repository at this point in the history
* Airbyte CDK native logger airbytehq#1279 - fix import logger error

* Airbyte CDK native logger airbytehq#1279 - source-paypal-transaction: change level from "WARN" to logging.WARN in self.logger.log

* Airbyte CDK native logger airbytehq#1279 - source-s3: use native logger instead AirbyteLogger

* Airbyte CDK native logger airbytehq#1279 - source-zuora: use native logger instead AirbyteLogger

* Airbyte CDK native logger airbytehq#1279 - fix get logger
  • Loading branch information
vitaliizazmic authored Oct 18, 2021
1 parent 1de7f4c commit 741001a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions airbyte-cdk/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.1.29
Fix import logger error

## 0.1.28
Added `check_config_against_spec` parameter to `Connector` abstract class
to allow skipping validating the input config against the spec for non-`check` calls
Expand Down
5 changes: 4 additions & 1 deletion airbyte-cdk/python/airbyte_cdk/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import argparse
import importlib
import logging
import os.path
import sys
import tempfile
Expand All @@ -15,11 +16,13 @@
from airbyte_cdk.sources import Source
from airbyte_cdk.sources.utils.schema_helpers import check_config_against_spec_or_exit, split_config

logger = init_logger("airbyte")


class AirbyteEntrypoint(object):
def __init__(self, source: Source):
self.source = source
self.logger = init_logger(getattr(source, "name", "source"))
self.logger = logging.getLogger(f"source.{getattr(source, 'name', '')}")

def parse_args(self, args: List[str]) -> argparse.Namespace:
# set up parent parsers
Expand Down
2 changes: 1 addition & 1 deletion airbyte-cdk/python/airbyte_cdk/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}


def init_logger(name: str):
def init_logger(name: str = None):
"""Initial set up of logger"""
logging.setLoggerClass(AirbyteNativeLogger)
logging.addLevelName(TRACE_LEVEL_NUM, "TRACE")
Expand Down
2 changes: 1 addition & 1 deletion airbyte-cdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name="airbyte-cdk",
version="0.1.28",
version="0.1.29",
description="A framework for writing Airbyte Connectors.",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#

import logging
import time
from abc import ABC
from datetime import datetime, timedelta
Expand Down Expand Up @@ -69,7 +70,7 @@ def __init__(
minimum_allowed_start_date = now - timedelta(**self.start_date_min)
if start_date < minimum_allowed_start_date:
self.logger.log(
"WARN",
logging.WARN,
f'Stream {self.name}: start_date "{start_date.isoformat()}" is too old. '
+ f'Reset start_date to the minimum_allowed_start_date "{minimum_allowed_start_date.isoformat()}"',
)
Expand All @@ -78,7 +79,7 @@ def __init__(
self.maximum_allowed_start_date = min(now, self.end_date)
if start_date > self.maximum_allowed_start_date:
self.logger.log(
"WARN",
logging.WARN,
f'Stream {self.name}: start_date "{start_date.isoformat()}" is too recent. '
+ f'Reset start_date to the maximum_allowed_start_date "{self.maximum_allowed_start_date.isoformat()}"',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def __init__(self, dataset: str, provider: dict, format: dict, path_pattern: str
self._schema = self._parse_user_input_schema(schema)
self.master_schema = None
self.storagefile_cache: Optional[List[Tuple[datetime, StorageFile]]] = None
self.logger = AirbyteLogger()
self.logger.info(f"initialised stream with format: {format}")

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class ZuoraStream(HttpStream, ABC):

def __init__(self, config: Dict):
super().__init__(authenticator=config["authenticator"])
self.logger = AirbyteLogger()
self._url_base = config["url_base"]
self.start_date = config["start_date"]
self.window_in_days = config["window_in_days"]
Expand Down

0 comments on commit 741001a

Please sign in to comment.