Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Lindell committed May 8, 2024
1 parent 357e37e commit 2b414e0
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions target_bigquery/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
from __future__ import annotations

import json
import uuid
import time
import uuid
from datetime import datetime, timedelta
from gzip import GzipFile
from gzip import open as gzip_open
from pathlib import Path
from tempfile import mkstemp
from typing import IO, Any, BinaryIO, Dict, List, Optional, Sequence

from google.api_core.exceptions import GoogleAPICallError

from fastavro import parse_schema, writer
from google.api_core.exceptions import GoogleAPICallError
from google.cloud import bigquery
# from google.cloud.bigquery import DEFAULT_RETRY

from singer_sdk.helpers._batch import (
BaseBatchFileEncoding,
BatchFileFormat,
Expand All @@ -29,6 +26,10 @@
from .avro import avro_schema, fix_recursive_types_in_dict
from .bq import column_type, get_client

# from google.cloud.bigquery import DEFAULT_RETRY



PARTITIONS = "partitions"


Expand Down Expand Up @@ -398,7 +399,8 @@ def transform_record(record):
try:
result = load_job.result()
self.logger.info(
f"[{self.stream_name}][{batch_id}] result.eror { result.errors }")
f"[{self.stream_name}][{batch_id}] result.eror { result.errors }"
)
# suggested?
# result = load_job.result(DEFAULT_RETRY.with_deadline(60), 500)

Expand All @@ -423,15 +425,19 @@ def transform_record(record):

except GoogleAPICallError as e:
# Handle Google API call errors
self.logger.info(f"[{self.stream_name}][{batch_id}] Google API call error: {e}")
self.logger.info(
f"[{self.stream_name}][{batch_id}] Google API call error: {e}"
)
except TimeoutError:
# Handle timeout errors
self.logger.info(f"[{self.stream_name}][{batch_id}] Timeout error: Job did not complete in the given timeout.")
self.logger.info(
f"[{self.stream_name}][{batch_id}] Timeout error: Job did not complete in the given timeout."
)
except Exception as e:
# Handle other unexpected errors
self.logger.info(f"[{self.stream_name}][{batch_id}] An unexpected error occurred: {e}")


self.logger.info(
f"[{self.stream_name}][{batch_id}] An unexpected error occurred: {e}"
)

def process_batch_files(
self,
Expand Down

0 comments on commit 2b414e0

Please sign in to comment.