airbyte-cdk 6.48.16__py3-none-any.whl → 6.48.16.post14.dev15122056170__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airbyte_cdk/cli/source_declarative_manifest/_run.py +69 -10
- airbyte_cdk/connector.py +3 -3
- airbyte_cdk/entrypoint.py +36 -0
- {airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/METADATA +1 -1
- {airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/RECORD +9 -9
- {airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/LICENSE_SHORT +0 -0
- {airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/entry_points.txt +0 -0
@@ -16,15 +16,17 @@ source-declarative-manifest spec
|
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
19
|
+
import argparse
|
19
20
|
import json
|
20
21
|
import pkgutil
|
21
22
|
import sys
|
22
23
|
import traceback
|
23
|
-
from collections.abc import
|
24
|
+
from collections.abc import MutableMapping
|
24
25
|
from pathlib import Path
|
25
26
|
from typing import Any, cast
|
26
27
|
|
27
28
|
import orjson
|
29
|
+
import yaml
|
28
30
|
|
29
31
|
from airbyte_cdk.entrypoint import AirbyteEntrypoint, launch
|
30
32
|
from airbyte_cdk.models import (
|
@@ -54,7 +56,7 @@ class SourceLocalYaml(YamlDeclarativeSource):
|
|
54
56
|
def __init__(
|
55
57
|
self,
|
56
58
|
catalog: ConfiguredAirbyteCatalog | None,
|
57
|
-
config:
|
59
|
+
config: MutableMapping[str, Any] | None,
|
58
60
|
state: TState,
|
59
61
|
**kwargs: Any,
|
60
62
|
) -> None:
|
@@ -91,7 +93,8 @@ def handle_command(args: list[str]) -> None:
|
|
91
93
|
|
92
94
|
def _get_local_yaml_source(args: list[str]) -> SourceLocalYaml:
|
93
95
|
try:
|
94
|
-
|
96
|
+
parsed_args = AirbyteEntrypoint.parse_args(args)
|
97
|
+
config, catalog, state = _parse_inputs_into_config_catalog_state(parsed_args)
|
95
98
|
return SourceLocalYaml(config=config, catalog=catalog, state=state)
|
96
99
|
except Exception as error:
|
97
100
|
print(
|
@@ -162,14 +165,30 @@ def create_declarative_source(
|
|
162
165
|
connector builder.
|
163
166
|
"""
|
164
167
|
try:
|
165
|
-
config:
|
168
|
+
config: MutableMapping[str, Any] | None
|
166
169
|
catalog: ConfiguredAirbyteCatalog | None
|
167
170
|
state: list[AirbyteStateMessage]
|
168
|
-
|
169
|
-
|
171
|
+
|
172
|
+
parsed_args = AirbyteEntrypoint.parse_args(args)
|
173
|
+
config, catalog, state = _parse_inputs_into_config_catalog_state(parsed_args)
|
174
|
+
|
175
|
+
if config is None:
|
176
|
+
raise ValueError(
|
177
|
+
"Invalid config: `__injected_declarative_manifest` should be provided at the root "
|
178
|
+
"of the config or using the --manifest-path argument."
|
179
|
+
)
|
180
|
+
|
181
|
+
# If a manifest_path is provided in the args, inject it into the config
|
182
|
+
if hasattr(parsed_args, "manifest_path") and parsed_args.manifest_path:
|
183
|
+
injected_manifest = _parse_manifest_from_file(parsed_args.manifest_path)
|
184
|
+
if injected_manifest:
|
185
|
+
config["__injected_declarative_manifest"] = injected_manifest
|
186
|
+
|
187
|
+
if "__injected_declarative_manifest" not in config:
|
170
188
|
raise ValueError(
|
171
189
|
"Invalid config: `__injected_declarative_manifest` should be provided at the root "
|
172
|
-
|
190
|
+
"of the config or using the --manifest-path argument. "
|
191
|
+
f"Config only has keys: {list(config.keys() if config else [])}"
|
173
192
|
)
|
174
193
|
if not isinstance(config["__injected_declarative_manifest"], dict):
|
175
194
|
raise ValueError(
|
@@ -177,6 +196,9 @@ def create_declarative_source(
|
|
177
196
|
f"but got type: {type(config['__injected_declarative_manifest'])}"
|
178
197
|
)
|
179
198
|
|
199
|
+
if hasattr(parsed_args, "components_path") and parsed_args.components_path:
|
200
|
+
_register_components_from_file(parsed_args.components_path)
|
201
|
+
|
180
202
|
return ConcurrentDeclarativeSource(
|
181
203
|
config=config,
|
182
204
|
catalog=catalog,
|
@@ -205,13 +227,12 @@ def create_declarative_source(
|
|
205
227
|
|
206
228
|
|
207
229
|
def _parse_inputs_into_config_catalog_state(
|
208
|
-
|
230
|
+
parsed_args: argparse.Namespace,
|
209
231
|
) -> tuple[
|
210
|
-
|
232
|
+
MutableMapping[str, Any] | None,
|
211
233
|
ConfiguredAirbyteCatalog | None,
|
212
234
|
list[AirbyteStateMessage],
|
213
235
|
]:
|
214
|
-
parsed_args = AirbyteEntrypoint.parse_args(args)
|
215
236
|
config = (
|
216
237
|
ConcurrentDeclarativeSource.read_config(parsed_args.config)
|
217
238
|
if hasattr(parsed_args, "config")
|
@@ -231,6 +252,44 @@ def _parse_inputs_into_config_catalog_state(
|
|
231
252
|
return config, catalog, state
|
232
253
|
|
233
254
|
|
255
|
+
def _parse_manifest_from_file(filepath: str) -> dict[str, Any] | None:
|
256
|
+
"""Extract and parse a manifest file specified in the args."""
|
257
|
+
try:
|
258
|
+
with open(filepath, "r", encoding="utf-8") as manifest_file:
|
259
|
+
manifest_content = yaml.safe_load(manifest_file)
|
260
|
+
if manifest_content is None:
|
261
|
+
raise ValueError(f"Manifest file at {filepath} is empty")
|
262
|
+
if not isinstance(manifest_content, dict):
|
263
|
+
raise ValueError(f"Manifest must be a dictionary, got {type(manifest_content)}")
|
264
|
+
return manifest_content
|
265
|
+
except Exception as error:
|
266
|
+
raise ValueError(f"Failed to load manifest file from {filepath}: {error}")
|
267
|
+
|
268
|
+
|
269
|
+
def _register_components_from_file(filepath: str) -> None:
|
270
|
+
"""Load and register components from a Python file specified in the args."""
|
271
|
+
import importlib.util
|
272
|
+
import sys
|
273
|
+
|
274
|
+
components_path = Path(filepath)
|
275
|
+
|
276
|
+
module_name = "components"
|
277
|
+
sdm_module_name = "source_declarative_manifest.components"
|
278
|
+
|
279
|
+
# Create module spec
|
280
|
+
spec = importlib.util.spec_from_file_location(module_name, components_path)
|
281
|
+
if spec is None or spec.loader is None:
|
282
|
+
raise ImportError(f"Could not load module from {components_path}")
|
283
|
+
|
284
|
+
# Create module and execute code, registering the module before executing its code
|
285
|
+
# To avoid issues with dataclasses that look up the module
|
286
|
+
module = importlib.util.module_from_spec(spec)
|
287
|
+
sys.modules[module_name] = module
|
288
|
+
sys.modules[sdm_module_name] = module
|
289
|
+
|
290
|
+
spec.loader.exec_module(module)
|
291
|
+
|
292
|
+
|
234
293
|
def run() -> None:
|
235
294
|
args: list[str] = sys.argv[1:]
|
236
295
|
handle_command(args)
|
airbyte_cdk/connector.py
CHANGED
@@ -8,7 +8,7 @@ import logging
|
|
8
8
|
import os
|
9
9
|
import pkgutil
|
10
10
|
from abc import ABC, abstractmethod
|
11
|
-
from typing import Any, Generic, Mapping, Optional, Protocol, TypeVar
|
11
|
+
from typing import Any, Generic, Mapping, MutableMapping, Optional, Protocol, TypeVar
|
12
12
|
|
13
13
|
import yaml
|
14
14
|
|
@@ -41,9 +41,9 @@ class BaseConnector(ABC, Generic[TConfig]):
|
|
41
41
|
"""
|
42
42
|
|
43
43
|
@staticmethod
|
44
|
-
def read_config(config_path: str) ->
|
44
|
+
def read_config(config_path: str) -> MutableMapping[str, Any]:
|
45
45
|
config = BaseConnector._read_json_file(config_path)
|
46
|
-
if isinstance(config,
|
46
|
+
if isinstance(config, MutableMapping):
|
47
47
|
return config
|
48
48
|
else:
|
49
49
|
raise ValueError(
|
airbyte_cdk/entrypoint.py
CHANGED
@@ -84,6 +84,18 @@ class AirbyteEntrypoint(object):
|
|
84
84
|
required_check_parser.add_argument(
|
85
85
|
"--config", type=str, required=True, help="path to the json configuration file"
|
86
86
|
)
|
87
|
+
check_parser.add_argument(
|
88
|
+
"--manifest-path",
|
89
|
+
type=str,
|
90
|
+
required=False,
|
91
|
+
help="path to the YAML manifest file to inject into the config",
|
92
|
+
)
|
93
|
+
check_parser.add_argument(
|
94
|
+
"--components-path",
|
95
|
+
type=str,
|
96
|
+
required=False,
|
97
|
+
help="path to the custom components file, if it exists",
|
98
|
+
)
|
87
99
|
|
88
100
|
# discover
|
89
101
|
discover_parser = subparsers.add_parser(
|
@@ -95,6 +107,18 @@ class AirbyteEntrypoint(object):
|
|
95
107
|
required_discover_parser.add_argument(
|
96
108
|
"--config", type=str, required=True, help="path to the json configuration file"
|
97
109
|
)
|
110
|
+
discover_parser.add_argument(
|
111
|
+
"--manifest-path",
|
112
|
+
type=str,
|
113
|
+
required=False,
|
114
|
+
help="path to the YAML manifest file to inject into the config",
|
115
|
+
)
|
116
|
+
discover_parser.add_argument(
|
117
|
+
"--components-path",
|
118
|
+
type=str,
|
119
|
+
required=False,
|
120
|
+
help="path to the custom components file, if it exists",
|
121
|
+
)
|
98
122
|
|
99
123
|
# read
|
100
124
|
read_parser = subparsers.add_parser(
|
@@ -114,6 +138,18 @@ class AirbyteEntrypoint(object):
|
|
114
138
|
required=True,
|
115
139
|
help="path to the catalog used to determine which data to read",
|
116
140
|
)
|
141
|
+
read_parser.add_argument(
|
142
|
+
"--manifest-path",
|
143
|
+
type=str,
|
144
|
+
required=False,
|
145
|
+
help="path to the YAML manifest file to inject into the config",
|
146
|
+
)
|
147
|
+
read_parser.add_argument(
|
148
|
+
"--components-path",
|
149
|
+
type=str,
|
150
|
+
required=False,
|
151
|
+
help="path to the custom components file, if it exists",
|
152
|
+
)
|
117
153
|
|
118
154
|
return main_parser.parse_args(args)
|
119
155
|
|
{airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/RECORD
RENAMED
@@ -8,10 +8,10 @@ airbyte_cdk/cli/airbyte_cdk/_secrets.py,sha256=jLtpkhFJHavABN3UuqddeDRGS8v1iEj0e
|
|
8
8
|
airbyte_cdk/cli/airbyte_cdk/_version.py,sha256=ohZNIktLFk91sdzqFW5idaNrZAPX2dIRnz---_fcKOE,352
|
9
9
|
airbyte_cdk/cli/airbyte_cdk/exceptions.py,sha256=bsGmlWN6cXL2jCD1WYAZMqFmK1OLg2xLrcC_60KHSeA,803
|
10
10
|
airbyte_cdk/cli/source_declarative_manifest/__init__.py,sha256=-0ST722Nj65bgRokzpzPkD1NBBW5CytEHFUe38cB86Q,91
|
11
|
-
airbyte_cdk/cli/source_declarative_manifest/_run.py,sha256=
|
11
|
+
airbyte_cdk/cli/source_declarative_manifest/_run.py,sha256=3ZXAic1MJkDyjfOGvcmmkIDY5vAqsNPp8A7Z8xjzm-A,10829
|
12
12
|
airbyte_cdk/cli/source_declarative_manifest/spec.json,sha256=Earc1L6ngcdIr514oFQlUoOxdF4RHqtUyStSIAquXdY,554
|
13
13
|
airbyte_cdk/config_observation.py,sha256=7SSPxtN0nXPkm4euGNcTTr1iLbwUL01jy-24V1Hzde0,3986
|
14
|
-
airbyte_cdk/connector.py,sha256=
|
14
|
+
airbyte_cdk/connector.py,sha256=N6TUlrZOMjLAI85JrNAKkfyTqnO5xfBCw4oEfgjJd9o,4254
|
15
15
|
airbyte_cdk/connector_builder/README.md,sha256=Hw3wvVewuHG9-QgsAq1jDiKuLlStDxKBz52ftyNRnBw,1665
|
16
16
|
airbyte_cdk/connector_builder/__init__.py,sha256=4Hw-PX1-VgESLF16cDdvuYCzGJtHntThLF4qIiULWeo,61
|
17
17
|
airbyte_cdk/connector_builder/connector_builder_handler.py,sha256=OFTzxyfAevI3Um8fXTOLTgoCc4Sx9NzF0boqYkAATfM,6590
|
@@ -33,7 +33,7 @@ airbyte_cdk/destinations/vector_db_based/indexer.py,sha256=beiSi2Uu67EoTr7yQSaCJ
|
|
33
33
|
airbyte_cdk/destinations/vector_db_based/test_utils.py,sha256=MkqLiOJ5QyKbV4rNiJhe-BHM7FD-ADHQ4bQGf4c5lRY,1932
|
34
34
|
airbyte_cdk/destinations/vector_db_based/utils.py,sha256=FOyEo8Lc-fY8UyhpCivhZtIqBRyxf3cUt6anmK03fUY,1127
|
35
35
|
airbyte_cdk/destinations/vector_db_based/writer.py,sha256=nZ00xPiohElJmYktEZZIhr0m5EDETCHGhg0Lb2S7A20,5095
|
36
|
-
airbyte_cdk/entrypoint.py,sha256=
|
36
|
+
airbyte_cdk/entrypoint.py,sha256=R2kAsAnCAI7eZCctQpMCImLhFFwo7PniJVA0e7RhJVI,19774
|
37
37
|
airbyte_cdk/exception_handler.py,sha256=D_doVl3Dt60ASXlJsfviOCswxGyKF2q0RL6rif3fNks,2013
|
38
38
|
airbyte_cdk/logger.py,sha256=1cURbvawbunCAV178q-XhTHcbAQZTSf07WhU7U9AXWU,3744
|
39
39
|
airbyte_cdk/manifest_migrations/README.md,sha256=PvnbrW1gyzhlkeucd0YAOXcXVxi0xBUUynzs4DMqjDo,2942
|
@@ -419,9 +419,9 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EDxgROHDbfG-QKQb59m7h_7crN1tRiawdf5uU7G
|
|
419
419
|
airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
|
420
420
|
airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
|
421
421
|
airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
|
422
|
-
airbyte_cdk-6.48.16.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
|
423
|
-
airbyte_cdk-6.48.16.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
|
424
|
-
airbyte_cdk-6.48.16.dist-info/METADATA,sha256=
|
425
|
-
airbyte_cdk-6.48.16.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
426
|
-
airbyte_cdk-6.48.16.dist-info/entry_points.txt,sha256=AKWbEkHfpzzk9nF9tqBUaw1MbvTM4mGtEzmZQm0ZWvM,139
|
427
|
-
airbyte_cdk-6.48.16.dist-info/RECORD,,
|
422
|
+
airbyte_cdk-6.48.16.post14.dev15122056170.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
|
423
|
+
airbyte_cdk-6.48.16.post14.dev15122056170.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
|
424
|
+
airbyte_cdk-6.48.16.post14.dev15122056170.dist-info/METADATA,sha256=4-aZbDzT7hC6E84o6NC0UDVyW0zanMyD7b_T-i_GH6o,6366
|
425
|
+
airbyte_cdk-6.48.16.post14.dev15122056170.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
426
|
+
airbyte_cdk-6.48.16.post14.dev15122056170.dist-info/entry_points.txt,sha256=AKWbEkHfpzzk9nF9tqBUaw1MbvTM4mGtEzmZQm0ZWvM,139
|
427
|
+
airbyte_cdk-6.48.16.post14.dev15122056170.dist-info/RECORD,,
|
{airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/LICENSE.txt
RENAMED
File without changes
|
{airbyte_cdk-6.48.16.dist-info → airbyte_cdk-6.48.16.post14.dev15122056170.dist-info}/LICENSE_SHORT
RENAMED
File without changes
|
File without changes
|
File without changes
|