Skip to content

Commit e8567bc

Browse files
committed
fix: patch ruff and mypy issues
Fix formatting and type conflicts
1 parent cd359a1 commit e8567bc

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

workloads/ingest/ingest/core/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010

1111
class DatabaseType(str, Enum):
1212
"""Database type enumeration."""
13-
13+
1414
MYSQL = "mysql"
1515
POSTGRES = "postgres"
1616

1717

1818
class TargetType(str, Enum):
1919
"""Target type enumeration."""
20-
20+
2121
BIGQUERY = "bigquery"
2222

2323

2424
class SourceConfig(BaseModel):
2525
"""Source database configuration."""
26-
26+
2727
name: str
2828
type: DatabaseType
2929
host: str
@@ -51,7 +51,7 @@ def build_connection_string(self, dialect: str, default_port: int = 0) -> str:
5151

5252
class BigQueryTargetConfig(BaseModel):
5353
"""BigQuery target configuration."""
54-
54+
5555
name: str
5656
type: TargetType = TargetType.BIGQUERY
5757
project_id: str = Field(
@@ -77,23 +77,23 @@ class BigQueryTargetConfig(BaseModel):
7777

7878
class RuntimeParams(BaseModel):
7979
"""Runtime parameters for ingestion process."""
80-
80+
8181
retry_attempts: int = Field(ge=1, le=10, default=3)
8282
retry_delay_seconds: int = Field(ge=1, le=3600, default=30)
8383
chunk_size: int = Field(default=10000)
8484

8585

8686
class SecretProvider(str, Enum):
8787
"""Secret provider enumeration."""
88-
88+
8989
GOOGLE_SECRET_MANAGER = "gcloud"
9090
# AWS_SECRET_MANAGER = "aws"
9191
# AZURE_KEY_VAULT = "azure"
9292

9393

9494
class SecretConfig(BaseModel):
9595
"""Secret configuration."""
96-
96+
9797
provider: SecretProvider = Field(
9898
default=SecretProvider.GOOGLE_SECRET_MANAGER, description="Secret Manager Provider"
9999
)
@@ -107,7 +107,7 @@ class SecretConfig(BaseModel):
107107

108108
class Config(BaseModel):
109109
"""Main configuration class."""
110-
110+
111111
version: str
112112
params: RuntimeParams
113113
secrets: List[SecretConfig]

workloads/ingest/ingest/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def process_source(
129129
source_config.password = config.get_gcloud_secret_value(source_config.password, env)
130130

131131
source = create_source(
132-
source_config, retry_attempts=config.params.retry_attempts, retry_delay=config.params.retry_delay
132+
source_config, retry_attempts=config.params.retry_attempts, retry_delay=config.params.retry_delay_seconds
133133
)
134134
try:
135135
# Process each table from this source

workloads/ingest/ingest/sources/mysql_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""MySQL source implementation."""
22

3-
from typing import Optional, Iterator
3+
from typing import Optional, Iterator, List
44
from .source import Source
55
from ..extractors import BaseExtractor
66
from ..core.config import SourceConfig
@@ -29,7 +29,7 @@ def connect(self) -> None:
2929
super().connect()
3030
logger.debug("MySQL source connected via BaseExtractor")
3131

32-
def extract(self, table: Table, chunk_size: int, limit: Optional[int] = None) -> Iterator[dict]:
32+
def extract(self, table: Table, chunk_size: int, limit: Optional[int] = None) -> Iterator[List[dict]]:
3333
"""Extract data from MySQL table."""
3434
if not self.extractor:
3535
raise RuntimeError("MySQL extractor not initialized")

workloads/ingest/ingest/sources/postgres_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""PostgreSQL source implementation."""
22

3-
from typing import Optional, Iterator
3+
from typing import Optional, Iterator, List
44
from .source import Source
55
from ..extractors import BaseExtractor
66
from ..core.config import SourceConfig
@@ -29,7 +29,7 @@ def connect(self) -> None:
2929
super().connect()
3030
logger.debug("PostgreSQL source connected via BaseExtractor")
3131

32-
def extract(self, table: Table, chunk_size: int, limit: Optional[int] = None) -> Iterator[dict]:
32+
def extract(self, table: Table, chunk_size: int, limit: Optional[int] = None) -> Iterator[List[dict]]:
3333
"""Extract data from PostgreSQL table."""
3434
if not self.extractor:
3535
raise RuntimeError("PostgreSQL extractor not initialized")

workloads/ingest/ingest/sources/source.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Source interface and base implementations."""
22

3-
from typing import Optional, Protocol, runtime_checkable, Iterator
3+
from typing import Optional, Protocol, runtime_checkable, Iterator, List
44
from pydantic import BaseModel, Field, ConfigDict
55
from ..core.config import SourceConfig
66
from ..core.catalog import Table
@@ -20,12 +20,15 @@ class SourceInterface(Protocol):
2020
def connect(self) -> None:
2121
"""Connect to the data source."""
2222
...
23-
def extract(self, table: Table, chunk_size: int, limit: Optional[int] = None) -> Iterator[dict]:
23+
24+
def extract(self, table: Table, chunk_size: int, limit: Optional[int] = None) -> Iterator[List[dict]]:
2425
"""Extract data from the source."""
2526
...
27+
2628
def validate_connection(self) -> bool:
2729
"""Validate the connection to the source."""
2830
...
31+
2932
def close(self) -> None:
3033
"""Close the connection to the source."""
3134
...
@@ -49,7 +52,7 @@ def connect(self) -> None:
4952
if self.extractor:
5053
self.extractor.connect()
5154

52-
def extract(self, table: Table, chunk_size: int, limit: Optional[int] = None) -> Iterator[dict]:
55+
def extract(self, table: Table, chunk_size: int, limit: Optional[int] = None) -> Iterator[List[dict]]:
5356
"""Extract data from the source using SQLAlchemy with streaming.
5457
5558
Args:

workloads/ingest/ingest/targets/bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _build_client(self) -> bigquery.Client:
3838
raise e
3939
return client
4040

41-
def _get_write_disposition(self, write_disposition: ReplicationType) -> bigquery.WriteDisposition:
41+
def _get_write_disposition(self, write_disposition: ReplicationType) -> str:
4242
"""Get the write disposition for the data."""
4343
if write_disposition not in map_replication_type_to_write_disposition:
4444
raise ValueError(f"Invalid write disposition: {write_disposition}")

workloads/ingest/ingest/targets/target.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ class TargetInterface(Protocol):
1515

1616
config: TargetTypes
1717

18-
def load(self, data: list[dict], target_table: str) -> None:
18+
def load(self, data: list[dict], target_table: str, write_disposition: ReplicationType) -> None:
1919
"""Load data into the target."""
2020
...
21+
2122
def validate_connection(self) -> bool:
2223
"""Validate the connection to the target."""
2324
...

0 commit comments

Comments
 (0)