From 45fbf0439e74d0759203b98ed74af946fe367edf Mon Sep 17 00:00:00 2001 From: Aaron Steers Date: Mon, 19 Feb 2024 16:56:50 -0800 Subject: [PATCH] rename to SQLCacheBase --- airbyte/caches/__init__.py | 4 ++-- airbyte/caches/base.py | 10 +++++----- airbyte/caches/duckdb.py | 4 ++-- airbyte/caches/postgres.py | 4 ++-- airbyte/caches/snowflake.py | 4 ++-- tests/unit_tests/test_caches.py | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/airbyte/caches/__init__.py b/airbyte/caches/__init__.py index 5e880d40..4382e7d6 100644 --- a/airbyte/caches/__init__.py +++ b/airbyte/caches/__init__.py @@ -1,7 +1,7 @@ """Base module for all caches.""" from __future__ import annotations -from airbyte.caches.base import SQLCacheConfigBase +from airbyte.caches.base import SQLCacheBase from airbyte.caches.duckdb import DuckDBCache from airbyte.caches.postgres import PostgresCache, PostgresCacheConfig from airbyte.caches.snowflake import SnowflakeCacheConfig, SnowflakeSQLCache @@ -12,7 +12,7 @@ "DuckDBCache", "PostgresCache", "PostgresCacheConfig", - "SQLCacheConfigBase", + "SQLCacheBase", "SnowflakeCacheConfig", "SnowflakeSQLCache", ] diff --git a/airbyte/caches/base.py b/airbyte/caches/base.py index 1e777b4d..ca41e0ec 100644 --- a/airbyte/caches/base.py +++ b/airbyte/caches/base.py @@ -68,7 +68,7 @@ class SQLRuntimeError(Exception): """Raised when an SQL operation fails.""" -class SQLCacheConfigBase(CacheConfigBase): +class SQLCacheBase(CacheConfigBase): """Same as a regular config except it exposes the 'get_sql_alchemy_url()' method.""" schema_name: str = "airbyte_raw" @@ -92,7 +92,7 @@ def get_database_name(self) -> str: ... -class GenericSQLCacheConfig(SQLCacheConfigBase): +class GenericSQLCacheConfig(SQLCacheBase): """Allows configuring 'sql_alchemy_url' directly.""" sql_alchemy_url: str @@ -110,7 +110,7 @@ class SQLCacheInstanceBase(RecordProcessor): """ type_converter_class: type[SQLTypeConverter] = SQLTypeConverter - config_class: type[SQLCacheConfigBase] + config_class: type[SQLCacheBase] file_writer_class: type[FileWriterBase] supports_merge_insert = False @@ -121,10 +121,10 @@ class SQLCacheInstanceBase(RecordProcessor): @final # We don't want subclasses to have to override the constructor. def __init__( self, - config: SQLCacheConfigBase | None = None, + config: SQLCacheBase | None = None, file_writer: FileWriterBase | None = None, ) -> None: - self.config: SQLCacheConfigBase + self.config: SQLCacheBase self._engine: Engine | None = None self._connection_to_reuse: Connection | None = None super().__init__(config) diff --git a/airbyte/caches/duckdb.py b/airbyte/caches/duckdb.py index 99463da5..0f31e128 100644 --- a/airbyte/caches/duckdb.py +++ b/airbyte/caches/duckdb.py @@ -12,7 +12,7 @@ from overrides import overrides from airbyte._file_writers import ParquetWriter, ParquetWriterConfig -from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheConfigBase +from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheBase from airbyte.telemetry import CacheTelemetryInfo @@ -24,7 +24,7 @@ ) -class DuckDBCache(SQLCacheConfigBase, ParquetWriterConfig): +class DuckDBCache(SQLCacheBase, ParquetWriterConfig): """A DuckDB cache. Also inherits config from the ParquetWriter, which is responsible for writing files to disk. diff --git a/airbyte/caches/postgres.py b/airbyte/caches/postgres.py index 3bcccfdf..b52b7369 100644 --- a/airbyte/caches/postgres.py +++ b/airbyte/caches/postgres.py @@ -7,11 +7,11 @@ from overrides import overrides from airbyte._file_writers import ParquetWriter, ParquetWriterConfig -from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheConfigBase +from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheBase from airbyte.telemetry import CacheTelemetryInfo -class PostgresCacheConfig(SQLCacheConfigBase, ParquetWriterConfig): +class PostgresCacheConfig(SQLCacheBase, ParquetWriterConfig): """Configuration for the Postgres cache. Also inherits config from the ParquetWriter, which is responsible for writing files to disk. diff --git a/airbyte/caches/snowflake.py b/airbyte/caches/snowflake.py index d362856c..00133722 100644 --- a/airbyte/caches/snowflake.py +++ b/airbyte/caches/snowflake.py @@ -15,7 +15,7 @@ from airbyte.caches.base import ( RecordDedupeMode, SQLCacheInstanceBase, - SQLCacheConfigBase, + SQLCacheBase, ) from airbyte.telemetry import CacheTelemetryInfo from airbyte.types import SQLTypeConverter @@ -27,7 +27,7 @@ from sqlalchemy.engine import Connection -class SnowflakeCacheConfig(SQLCacheConfigBase, ParquetWriterConfig): +class SnowflakeCacheConfig(SQLCacheBase, ParquetWriterConfig): """Configuration for the Snowflake cache. Also inherits config from the ParquetWriter, which is responsible for writing files to disk. diff --git a/tests/unit_tests/test_caches.py b/tests/unit_tests/test_caches.py index 6bb0ee31..1f2aee5b 100644 --- a/tests/unit_tests/test_caches.py +++ b/tests/unit_tests/test_caches.py @@ -5,7 +5,7 @@ import pytest from airbyte._file_writers import ParquetWriterConfig -from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheConfigBase +from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheBase from airbyte.caches.duckdb import DuckDBCacheBase, DuckDBCache @@ -27,7 +27,7 @@ def test_get_sql_alchemy_url_with_default_schema_name(): assert config.get_sql_alchemy_url() == 'duckdb:///test_path' def test_duck_db_cache_config_inheritance(): - assert issubclass(DuckDBCache, SQLCacheConfigBase) + assert issubclass(DuckDBCache, SQLCacheBase) assert issubclass(DuckDBCache, ParquetWriterConfig) def test_duck_db_cache_config_get_sql_alchemy_url(): @@ -54,7 +54,7 @@ def test_duck_db_cache_config_get_database_name_with_default_schema_name(): assert config.get_database_name() == 'test_db' def test_duck_db_cache_config_inheritance_from_sql_cache_config_base(): - assert issubclass(DuckDBCache, SQLCacheConfigBase) + assert issubclass(DuckDBCache, SQLCacheBase) def test_duck_db_cache_config_inheritance_from_parquet_writer_config(): assert issubclass(DuckDBCache, ParquetWriterConfig)