Skip to content

Commit 1fe042e

Browse files
committed
update config path
1 parent c2fdffa commit 1fe042e

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

airbyte_cdk/entrypoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def run(self, parsed_args: argparse.Namespace) -> Iterable[str]:
187187
raw_config = self.source.read_config(parsed_args.config)
188188
config = self.source.configure(raw_config, temp_dir)
189189
mutable_config = dict(config)
190-
config_path = self.extract_config(sys.argv[1:])
190+
config_path = parsed_args.config if parsed_args.config else None
191191
if config_path:
192192
self.source.migrate_config(config_path, mutable_config)
193193
self.source.transform_config(mutable_config)

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from copy import deepcopy
99
from importlib import metadata
1010
from types import ModuleType
11-
from typing import Any, Dict, Iterator, List, Mapping, MutableMapping, Optional, Set, cast
11+
from typing import Any, Dict, Iterator, List, Mapping, MutableMapping, Optional, Set
1212

1313
import yaml
1414
from jsonschema.exceptions import ValidationError
@@ -296,7 +296,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
296296

297297
return source_streams
298298

299-
def migrate_config(self, config_path: Optional[Any], config: MutableMapping[str, Any]) -> None:
299+
def migrate_config(self, config_path: Optional[str], config: MutableMapping[str, Any]) -> None:
300300
self._spec_component.migrate_config(config_path, config) if self._spec_component else None
301301

302302
def transform_config(self, config: MutableMapping[str, Any]) -> None:

airbyte_cdk/sources/declarative/spec/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def generate_spec(self) -> ConnectorSpecification:
6969
# We remap these keys to camel case because that's the existing format expected by the rest of the platform
7070
return ConnectorSpecificationSerializer.load(obj)
7171

72-
def migrate_config(self, config_path: Optional[Any], config: Mapping[str, Any]) -> None:
72+
def migrate_config(self, config_path: Optional[str], config: Mapping[str, Any]) -> None:
7373
"""
7474
Apply all specified config transformations to the provided config and save the modified config to the given path and emit a control message.
7575

airbyte_cdk/sources/source.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,14 @@ def name(self) -> str:
9494
"""Source name"""
9595
return self.__class__.__name__
9696

97-
def migrate_config(self, config_path: str, config: MutableMapping[str, Any]) -> None:
97+
def migrate_config(self, config_path: Optional[str], config: MutableMapping[str, Any]) -> None:
98+
"""
99+
Optional method to migrate config.
100+
"""
98101
pass
99102

100103
def transform_config(self, config: MutableMapping[str, Any]) -> None:
104+
"""
105+
Optional method to transform config.
106+
"""
101107
pass

unit_tests/sources/declarative/spec/test_spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def test_given_unmigrated_config_when_migrating_then_config_is_migrated(migratio
222222
)
223223
spec.message_repository = migration_mocks["message_repository"]
224224

225-
spec.migrate_config(["spec"], migration_mocks["source"], input_config)
225+
spec.migrate_config("/fake/config/path", input_config)
226226

227227
migration_mocks["message_repository"].emit_message.assert_called_once()
228228
migration_mocks["open"].assert_called_once_with("/fake/config/path", "w")
@@ -252,7 +252,7 @@ def test_given_already_migrated_config_no_control_message_is_emitted(migration_m
252252
)
253253
spec.message_repository = migration_mocks["message_repository"]
254254

255-
spec.migrate_config(["spec"], migration_mocks["source"], input_config)
255+
spec.migrate_config("/fake/config/path", input_config)
256256

257257
migration_mocks["message_repository"].emit_message.assert_not_called()
258258
migration_mocks["open"].assert_not_called()

0 commit comments

Comments
 (0)