Skip to content

Commit

Permalink
chore: replace AirbyteLogger with logging.Logger in connectors (#40215)
Browse files Browse the repository at this point in the history
Co-authored-by: btkcodedev <btk.codedev@gmail.com>
  • Loading branch information
natikgadzhi and btkcodedev committed Jun 27, 2024
1 parent 3187b1f commit 30643ae
Show file tree
Hide file tree
Showing 82 changed files with 114 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
#


import json
import logging
from typing import Any, Iterable, Mapping
from uuid import uuid4

import boto3
from airbyte_cdk import AirbyteLogger
from airbyte_cdk.destinations import Destination
from airbyte_cdk.models import AirbyteConnectionStatus, AirbyteMessage, ConfiguredAirbyteCatalog, Status, Type
from botocore.exceptions import ClientError
Expand Down Expand Up @@ -124,7 +124,7 @@ def write(
if message.type == Type.STATE:
yield message

def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
def check(self, logger: logging.Logger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
try:
# Required propeties
queue_url = config["queue_url"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#

import json
import logging
from typing import Any, Mapping

import pytest
from airbyte_cdk import AirbyteLogger
from airbyte_cdk.models import AirbyteStream, ConfiguredAirbyteCatalog, ConfiguredAirbyteStream, DestinationSyncMode, Status, SyncMode
from destination_amazon_sqs import DestinationAmazonSqs

Expand Down Expand Up @@ -37,10 +37,10 @@ def configured_catalog_fixture() -> ConfiguredAirbyteCatalog:


def test_check_valid_config(config: Mapping):
outcome = DestinationAmazonSqs().check(AirbyteLogger(), config)
outcome = DestinationAmazonSqs().check(logging.getLogger("airbyte"), config)
assert outcome.status == Status.SUCCEEDED


def test_check_invalid_config():
outcome = DestinationAmazonSqs().check(AirbyteLogger(), {"secret_key": "not_a_real_secret"})
outcome = DestinationAmazonSqs().check(logging.getLogger("airbyte"), {"secret_key": "not_a_real_secret"})
assert outcome.status == Status.FAILED
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data:
connectorSubtype: api
connectorType: destination
definitionId: 0eeee7fb-518f-4045-bacc-9619e31c43ea
dockerImageTag: 0.1.7
dockerImageTag: 0.1.8
dockerRepository: airbyte/destination-amazon-sqs
githubIssueLabel: destination-amazon-sqs
icon: awssqs.svg
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 = "0.1.7"
version = "0.1.8"
name = "destination-amazon-sqs"
description = "Destination implementation for Amazon Sqs."
authors = [ "Airbyte <contact@airbyte.io>",]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#

import json
import logging
import time
from typing import Any, Mapping

import boto3
from airbyte_cdk.logger import AirbyteLogger
from airbyte_cdk.models import AirbyteMessage, ConfiguredAirbyteCatalog, Status
from destination_amazon_sqs import DestinationAmazonSqs

Expand Down Expand Up @@ -88,7 +88,7 @@ def test_check():
# Create config
config = create_config(queue_url, queue_region, user["AccessKeyId"], user["SecretAccessKey"], 10)
# Create AirbyteLogger
logger = AirbyteLogger()
logger = logging.getLogger("airbyte")
# Create Destination
destination = DestinationAmazonSqs()
# Run check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#


import logging
from typing import Any, Iterable, Mapping

from airbyte_cdk import AirbyteLogger
from airbyte_cdk.destinations import Destination
from airbyte_cdk.destinations.vector_db_based.document_processor import DocumentProcessor
from airbyte_cdk.destinations.vector_db_based.embedder import Embedder, create_from_config
Expand Down Expand Up @@ -37,7 +37,7 @@ def write(
)
yield from writer.write(configured_catalog, input_messages)

def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
def check(self, logger: logging.Logger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
parsed_config = ConfigModel.parse_obj(config)
self._init_indexer(parsed_config)
checks = [self.embedder.check(), self.indexer.check(), DocumentProcessor.check_config(parsed_config.processing)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data:
connectorSubtype: database
connectorType: destination
definitionId: 042ce96f-1158-4662-9543-e2ff015be97a
dockerImageTag: 0.1.7
dockerImageTag: 0.1.8
dockerRepository: airbyte/destination-astra
githubIssueLabel: destination-astra
icon: astra.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "airbyte-destination-astra"
version = "0.1.7"
version = "0.1.8"
description = "Airbyte destination implementation for Astra DB."
authors = ["Airbyte <contact@airbyte.io>"]
license = "MIT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#

import logging
import unittest
from unittest.mock import MagicMock, Mock, patch

from airbyte_cdk import AirbyteLogger
from airbyte_cdk.models import ConnectorSpecification, Status
from destination_astra.config import ConfigModel
from destination_astra.destination import DestinationAstra
Expand All @@ -24,7 +24,7 @@ def setUp(self):
},
}
self.config_model = ConfigModel.parse_obj(self.config)
self.logger = AirbyteLogger()
self.logger = logging.getLogger("airbyte")

@patch("destination_astra.destination.AstraIndexer")
@patch("destination_astra.destination.create_from_config")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import Any, Dict, Iterable, Mapping

import pandas as pd
from airbyte_cdk import AirbyteLogger
from airbyte_cdk.destinations import Destination
from airbyte_cdk.models import AirbyteConnectionStatus, AirbyteMessage, AirbyteStateType, ConfiguredAirbyteCatalog, Status, Type
from botocore.exceptions import ClientError, InvalidRegionError
Expand Down Expand Up @@ -104,7 +103,7 @@ def write(
# Flush all or remaining records
self._flush_streams(streams)

def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
def check(self, logger: logging.Logger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
"""
Tests if the input configuration can be used to successfully connect to the destination with the needed permissions
e.g: if a provided API token or password can be used to connect and write to the destination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data:
definitionId: 99878c90-0fbd-46d3-9d98-ffde879d17fc
connectorBuildOptions:
baseImage: docker.io/airbyte/python-connector-base:1.2.2@sha256:57703de3b4c4204bd68a7b13c9300f8e03c0189bffddaffc796f1da25d2dbea0
dockerImageTag: 0.1.12
dockerImageTag: 0.1.13
dockerRepository: airbyte/destination-aws-datalake
githubIssueLabel: destination-aws-datalake
icon: awsdatalake.svg
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 = "0.1.12"
version = "0.1.13"
name = "destination-aws-datalake"
description = "Destination Implementation for AWS Datalake."
authors = [ "Airbyte <contact@airbyte.io>",]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#


import logging
from typing import Any, Iterable, Mapping

from airbyte_cdk import AirbyteLogger
from airbyte_cdk.destinations import Destination
from airbyte_cdk.destinations.vector_db_based.document_processor import DocumentProcessor
from airbyte_cdk.destinations.vector_db_based.embedder import Embedder, create_from_config
Expand Down Expand Up @@ -65,7 +65,7 @@ def write(
)
yield from writer.write(configured_catalog, input_messages)

def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
def check(self, logger: logging.Logger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
"""
Tests if the input configuration can be used to successfully connect to the destination with the needed permissions
e.g: if a provided API token or password can be used to connect and write to the destination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data:
connectorSubtype: vectorstore
connectorType: destination
definitionId: 0b75218b-f702-4a28-85ac-34d3d84c0fc2
dockerImageTag: 0.0.13
dockerImageTag: 0.0.14
dockerRepository: airbyte/destination-chroma
githubIssueLabel: destination-chroma
icon: chroma.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "airbyte-destination-chroma"
version = "0.0.13"
version = "0.0.14"
description = "Airbyte destination implementation for Chroma."
authors = ["Airbyte <contact@airbyte.io>"]
license = "MIT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#

import logging
import unittest
from unittest.mock import MagicMock, Mock, patch

from airbyte_cdk import AirbyteLogger
from airbyte_cdk.models import ConnectorSpecification, Status
from destination_chroma.config import ConfigModel
from destination_chroma.destination import DestinationChroma
Expand All @@ -22,7 +22,7 @@ def setUp(self):
},
}
self.config_model = ConfigModel.parse_obj(self.config)
self.logger = AirbyteLogger()
self.logger = logging.getLogger("airbyte")

@patch("destination_chroma.destination.ChromaIndexer")
@patch("destination_chroma.destination.create_from_config")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@


import json
import logging
from datetime import datetime
from logging import getLogger
from typing import Any, Iterable, Mapping
from uuid import uuid4

from airbyte_cdk import AirbyteLogger
from airbyte_cdk.destinations import Destination
from airbyte_cdk.models import AirbyteConnectionStatus, AirbyteMessage, ConfiguredAirbyteCatalog, DestinationSyncMode, Status, Type
from destination_databend.client import DatabendClient
Expand Down Expand Up @@ -65,7 +65,7 @@ def write(
# Flush any leftover messages
writer.flush()

def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
def check(self, logger: logging.Logger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
"""
Tests if the input configuration can be used to successfully connect to the destination with the needed permissions
e.g: if a provided API token or password can be used to connect and write to the destination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#

import logging
from collections import defaultdict
from datetime import datetime
from itertools import chain

from airbyte_cdk import AirbyteLogger
from airbyte_cdk.models import AirbyteConnectionStatus, Status
from destination_databend.client import DatabendClient

Expand Down Expand Up @@ -128,7 +128,7 @@ def flush(self) -> None:
self._flush()


def create_databend_wirter(client: DatabendClient, logger: AirbyteLogger) -> DatabendWriter:
def create_databend_wirter(client: DatabendClient, logger: logging.Logger) -> DatabendWriter:
logger.info("Using the SQL writing strategy")
writer = DatabendSQLWriter(client)
return writer
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data:
connectorSubtype: database
connectorType: destination
definitionId: 302e4d8e-08d3-4098-acd4-ac67ca365b88
dockerImageTag: 0.1.7
dockerImageTag: 0.1.8
dockerRepository: airbyte/destination-databend
githubIssueLabel: destination-databend
icon: databend.svg
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 = "0.1.7"
version = "0.1.8"
name = "destination-databend"
description = "Destination implementation for Databend."
authors = [ "Airbyte <contact@airbyte.io>",]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import duckdb
import pyarrow as pa

from airbyte_cdk import AirbyteLogger
import logging
from airbyte_cdk.destinations import Destination
from airbyte_cdk.models import AirbyteConnectionStatus, AirbyteMessage, ConfiguredAirbyteCatalog, DestinationSyncMode, Status, Type

Expand Down Expand Up @@ -163,7 +163,7 @@ def _safe_write(*, con: duckdb.DuckDBPyConnection, buffer: Dict[str, Dict[str, L
# local variable defined above.
con.sql(f"INSERT INTO {schema_name}.{table_name} SELECT * FROM pa_table")

def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
def check(self, logger: logging.Logger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
"""
Tests if the input configuration can be used to successfully connect to the destination with the needed permissions
e.g: if a provided API token or password can be used to connect and write to the destination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data:
connectorSubtype: database
connectorType: destination
definitionId: 94bd199c-2ff0-4aa2-b98e-17f0acb72610
dockerImageTag: 0.4.4
dockerImageTag: 0.4.5
dockerRepository: airbyte/destination-duckdb
githubIssueLabel: destination-duckdb
icon: duckdb.svg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "destination-duckdb"
version = "0.4.4"
version = "0.4.5"
description = "Destination implementation for Duckdb."
authors = ["Simon Späti, Airbyte"]
license = "MIT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#


import logging
from typing import Any, Iterable, Mapping

from airbyte_cdk import AirbyteLogger
from airbyte_cdk.destinations import Destination
from airbyte_cdk.destinations.vector_db_based.document_processor import DocumentProcessor
from airbyte_cdk.destinations.vector_db_based.embedder import Embedder, create_from_config
Expand Down Expand Up @@ -43,7 +43,7 @@ def write(
except Exception as e:
yield AirbyteMessage(type="LOG", log=AirbyteLogger(level="ERROR", message=str(e)))

def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
def check(self, logger: logging.Logger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
try:
parsed_config = ConfigModel.parse_obj(config)
init_status = self._init_indexer(parsed_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data:
connectorSubtype: vectorstore
connectorType: destination
definitionId: 3d2b6f84-7f0d-4e3f-a5e5-7c7d4b50eabd
dockerImageTag: 0.1.5
dockerImageTag: 0.1.6
dockerRepository: airbyte/destination-pinecone
documentationUrl: https://docs.airbyte.com/integrations/destinations/pinecone
githubIssueLabel: destination-pinecone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "airbyte-destination-pinecone"
version = "0.1.5"
version = "0.1.6"
description = "Airbyte destination implementation for Pinecone."
authors = ["Airbyte <contact@airbyte.io>"]
license = "MIT"
Expand Down
Loading

0 comments on commit 30643ae

Please sign in to comment.