Skip to content

Commit 5ca4561

Browse files
committed
encapsulate migrate and transform and return Config
1 parent 4e2e8fc commit 5ca4561

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
from airbyte_cdk.sources.declarative.spec.spec import Spec
6464
from airbyte_cdk.sources.message import MessageRepository
6565
from airbyte_cdk.sources.streams.core import Stream
66-
from airbyte_cdk.sources.types import ConnectionDefinition
66+
from airbyte_cdk.sources.types import Config, ConnectionDefinition
6767
from airbyte_cdk.sources.utils.slice_logger import (
6868
AlwaysLogSliceLogger,
6969
DebugSliceLogger,
@@ -150,11 +150,7 @@ def __init__(
150150
self._spec_component = (
151151
self._constructor.create_component(SpecModel, spec, dict()) if spec else None
152152
)
153-
mutable_config = dict(config) if config else {}
154-
self._migrate_config(config_path, mutable_config, config)
155-
if self._spec_component:
156-
self._spec_component.transform_config(mutable_config)
157-
self._config = mutable_config
153+
self._config = self._migrate_and_transform_config(config_path, config)
158154

159155
@property
160156
def resolved_manifest(self) -> Mapping[str, Any]:
@@ -216,13 +212,13 @@ def _normalize_manifest(self) -> None:
216212
normalizer = ManifestNormalizer(self._source_config, self._declarative_component_schema)
217213
self._source_config = normalizer.normalize()
218214

219-
def _migrate_config(
215+
def _migrate_and_transform_config(
220216
self,
221217
config_path: Optional[str],
222-
mutable_config: MutableMapping[str, Any],
223-
config: Optional[Mapping[str, Any]],
224-
) -> None:
225-
if config_path and config and self._spec_component:
218+
config: Optional[Config],
219+
) -> Config:
220+
mutable_config = dict(config) if config else {}
221+
if self._spec_component:
226222
self._spec_component.migrate_config(mutable_config)
227223
if mutable_config != config:
228224
if config_path:
@@ -235,6 +231,10 @@ def _migrate_config(
235231
for message in self.message_repository.consume_queue():
236232
print(orjson.dumps(AirbyteMessageSerializer.dump(message)).decode())
237233

234+
self._spec_component.transform_config(mutable_config)
235+
236+
return mutable_config
237+
238238
def _migrate_manifest(self) -> None:
239239
"""
240240
This method is used to migrate the manifest. It should be called after the manifest has been validated.

0 commit comments

Comments
 (0)