Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(source-google-sheets): Replace AirbyteLogger with logging.Logger #38249

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ data:
connectorSubtype: file
connectorType: source
definitionId: 71607ba1-c0ac-4799-8049-7f4b90dd50f7
dockerImageTag: 0.5.1
dockerImageTag: 0.5.2
dockerRepository: airbyte/source-google-sheets
documentationUrl: https://docs.airbyte.com/integrations/sources/google-sheets
githubIssueLabel: source-google-sheets
icon: google-sheets.svg
license: Elv2
maxSecondsBetweenMessages: 60
name: Google Sheets
remoteRegistries:
pypi:
enabled: true
packageName: airbyte-source-google-sheets
registries:
cloud:
enabled: true
oss:
enabled: true
releaseStage: generally_available
remoteRegistries:
pypi:
enabled: true
packageName: airbyte-source-google-sheets
supportLevel: certified
tags:
- language:python
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.5.1"
version = "0.5.2"
name = "source-google-sheets"
description = "Source implementation for Google Sheets."
authors = [ "Airbyte <[email protected]>",]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from datetime import datetime
from typing import Dict, FrozenSet, Iterable, List, Tuple

from airbyte_cdk.logger import AirbyteLogger
from airbyte_cdk.models.airbyte_protocol import AirbyteRecordMessage, AirbyteStream, ConfiguredAirbyteCatalog, SyncMode
from google.oauth2 import credentials as client_account
from google.oauth2 import service_account
Expand Down Expand Up @@ -43,7 +42,7 @@ def get_authenticated_google_credentials(credentials: Dict[str, str], scopes: Li
return client_account.Credentials.from_authorized_user_info(info=credentials)

@staticmethod
def headers_to_airbyte_stream(logger: AirbyteLogger, sheet_name: str, header_row_values: List[str]) -> AirbyteStream:
def headers_to_airbyte_stream(logger: logging.Logger, sheet_name: str, header_row_values: List[str]) -> AirbyteStream:
"""
Parses sheet headers from the provided row. This method assumes that data is contiguous
i.e: every cell contains a value and the first cell which does not contain a value denotes the end
Expand Down Expand Up @@ -194,7 +193,7 @@ def get_grid_sheets(spreadsheet_metadata) -> List[str]:
non_grid_sheets.append(sheet_title)

if non_grid_sheets:
AirbyteLogger().log("WARN", "Skip non-grid sheets: " + ", ".join(non_grid_sheets))
logging.getLogger("airbyte").log("WARN", "Skip non-grid sheets: " + ", ".join(non_grid_sheets))

return grid_sheets

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@


import json
import logging
import socket
from typing import Any, Generator, List, MutableMapping, Union

from airbyte_cdk.logger import AirbyteLogger
from airbyte_cdk.models import FailureType
from airbyte_cdk.models.airbyte_protocol import (
AirbyteCatalog,
Expand Down Expand Up @@ -43,7 +43,7 @@ class SourceGoogleSheets(Source):
Spreadsheets API Reference: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets
"""

def check(self, logger: AirbyteLogger, config: json) -> AirbyteConnectionStatus:
def check(self, logger: logging.Logger, config: json) -> AirbyteConnectionStatus:
# Check involves verifying that the specified spreadsheet is reachable with our credentials.
try:
client = GoogleSheetsClient(self.get_credentials(config))
Expand Down Expand Up @@ -108,7 +108,7 @@ def check(self, logger: AirbyteLogger, config: json) -> AirbyteConnectionStatus:

return AirbyteConnectionStatus(status=Status.SUCCEEDED)

def discover(self, logger: AirbyteLogger, config: json) -> AirbyteCatalog:
def discover(self, logger: logging.Logger, config: json) -> AirbyteCatalog:
client = GoogleSheetsClient(self.get_credentials(config))
spreadsheet_id = Helpers.get_spreadsheet_id(config["spreadsheet_id"])
try:
Expand Down Expand Up @@ -144,7 +144,7 @@ def discover(self, logger: AirbyteLogger, config: json) -> AirbyteCatalog:

def _read(
self,
logger: AirbyteLogger,
logger: logging.Logger,
config: json,
catalog: ConfiguredAirbyteCatalog,
) -> Generator[AirbyteMessage, None, None]:
Expand Down Expand Up @@ -208,7 +208,7 @@ def _read(

def read(
self,
logger: AirbyteLogger,
logger: logging.Logger,
config: json,
catalog: ConfiguredAirbyteCatalog,
state: Union[List[AirbyteStateMessage], MutableMapping[str, Any]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#


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

from airbyte_cdk.logger import AirbyteLogger
from airbyte_cdk.models.airbyte_protocol import (
AirbyteRecordMessage,
AirbyteStream,
Expand All @@ -19,7 +19,7 @@
from source_google_sheets.helpers import Helpers
from source_google_sheets.models import CellData, GridData, RowData, Sheet, SheetProperties, Spreadsheet

logger = AirbyteLogger()
logger = logging.getLogger("airbyte")


def google_sheet_client(row_data, spreadsheet_id, client):
Expand Down
Loading
Loading