airbyte-cdk 6.7.0rc2__py3-none-any.whl → 6.7.1__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.
Files changed (126) hide show
  1. airbyte_cdk/cli/__init__.py +1 -0
  2. airbyte_cdk/cli/source_declarative_manifest/__init__.py +6 -0
  3. airbyte_cdk/cli/source_declarative_manifest/_run.py +224 -0
  4. airbyte_cdk/cli/source_declarative_manifest/spec.json +17 -0
  5. airbyte_cdk/config_observation.py +2 -1
  6. airbyte_cdk/connector.py +1 -0
  7. airbyte_cdk/connector_builder/connector_builder_handler.py +1 -1
  8. airbyte_cdk/connector_builder/main.py +2 -1
  9. airbyte_cdk/destinations/destination.py +2 -1
  10. airbyte_cdk/destinations/vector_db_based/config.py +2 -1
  11. airbyte_cdk/destinations/vector_db_based/document_processor.py +4 -3
  12. airbyte_cdk/destinations/vector_db_based/embedder.py +5 -4
  13. airbyte_cdk/entrypoint.py +3 -2
  14. airbyte_cdk/logger.py +2 -1
  15. airbyte_cdk/models/__init__.py +2 -0
  16. airbyte_cdk/models/airbyte_protocol.py +2 -1
  17. airbyte_cdk/sources/concurrent_source/concurrent_read_processor.py +3 -3
  18. airbyte_cdk/sources/concurrent_source/concurrent_source.py +1 -1
  19. airbyte_cdk/sources/config.py +2 -1
  20. airbyte_cdk/sources/declarative/auth/jwt.py +1 -0
  21. airbyte_cdk/sources/declarative/auth/oauth.py +1 -0
  22. airbyte_cdk/sources/declarative/auth/selective_authenticator.py +1 -0
  23. airbyte_cdk/sources/declarative/auth/token.py +2 -1
  24. airbyte_cdk/sources/declarative/auth/token_provider.py +3 -2
  25. airbyte_cdk/sources/declarative/concurrent_declarative_source.py +24 -54
  26. airbyte_cdk/sources/declarative/declarative_component_schema.yaml +180 -13
  27. airbyte_cdk/sources/declarative/decoders/json_decoder.py +3 -2
  28. airbyte_cdk/sources/declarative/decoders/noop_decoder.py +1 -0
  29. airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py +1 -0
  30. airbyte_cdk/sources/declarative/decoders/xml_decoder.py +1 -0
  31. airbyte_cdk/sources/declarative/extractors/dpath_extractor.py +1 -0
  32. airbyte_cdk/sources/declarative/extractors/http_selector.py +1 -0
  33. airbyte_cdk/sources/declarative/extractors/record_filter.py +6 -48
  34. airbyte_cdk/sources/declarative/extractors/record_selector.py +32 -4
  35. airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py +2 -1
  36. airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py +2 -1
  37. airbyte_cdk/sources/declarative/incremental/global_substream_cursor.py +5 -2
  38. airbyte_cdk/sources/declarative/incremental/per_partition_cursor.py +5 -2
  39. airbyte_cdk/sources/declarative/incremental/per_partition_with_global.py +1 -3
  40. airbyte_cdk/sources/declarative/interpolation/jinja.py +5 -4
  41. airbyte_cdk/sources/declarative/manifest_declarative_source.py +4 -3
  42. airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py +1 -1
  43. airbyte_cdk/sources/declarative/models/declarative_component_schema.py +122 -0
  44. airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +26 -17
  45. airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py +1 -0
  46. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py +1 -0
  47. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py +1 -0
  48. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py +1 -0
  49. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py +1 -0
  50. airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py +1 -0
  51. airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py +1 -0
  52. airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py +1 -0
  53. airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py +1 -0
  54. airbyte_cdk/sources/declarative/requesters/http_job_repository.py +2 -1
  55. airbyte_cdk/sources/declarative/requesters/http_requester.py +1 -0
  56. airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py +1 -0
  57. airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py +1 -0
  58. airbyte_cdk/sources/declarative/requesters/paginators/paginator.py +1 -0
  59. airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py +1 -0
  60. airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py +1 -0
  61. airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py +1 -0
  62. airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py +1 -0
  63. airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py +9 -3
  64. airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py +2 -1
  65. airbyte_cdk/sources/declarative/requesters/requester.py +1 -0
  66. airbyte_cdk/sources/declarative/retrievers/async_retriever.py +2 -1
  67. airbyte_cdk/sources/declarative/retrievers/simple_retriever.py +12 -4
  68. airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py +7 -4
  69. airbyte_cdk/sources/declarative/transformations/add_fields.py +1 -0
  70. airbyte_cdk/sources/declarative/transformations/remove_fields.py +1 -0
  71. airbyte_cdk/sources/declarative/yaml_declarative_source.py +1 -0
  72. airbyte_cdk/sources/embedded/tools.py +1 -0
  73. airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py +2 -1
  74. airbyte_cdk/sources/file_based/config/avro_format.py +2 -1
  75. airbyte_cdk/sources/file_based/config/csv_format.py +2 -1
  76. airbyte_cdk/sources/file_based/config/excel_format.py +2 -1
  77. airbyte_cdk/sources/file_based/config/file_based_stream_config.py +2 -1
  78. airbyte_cdk/sources/file_based/config/jsonl_format.py +2 -1
  79. airbyte_cdk/sources/file_based/config/parquet_format.py +2 -1
  80. airbyte_cdk/sources/file_based/config/unstructured_format.py +2 -1
  81. airbyte_cdk/sources/file_based/file_based_source.py +2 -1
  82. airbyte_cdk/sources/file_based/file_based_stream_reader.py +2 -1
  83. airbyte_cdk/sources/file_based/file_types/avro_parser.py +1 -0
  84. airbyte_cdk/sources/file_based/file_types/csv_parser.py +2 -1
  85. airbyte_cdk/sources/file_based/file_types/excel_parser.py +5 -5
  86. airbyte_cdk/sources/file_based/file_types/jsonl_parser.py +2 -1
  87. airbyte_cdk/sources/file_based/file_types/parquet_parser.py +2 -1
  88. airbyte_cdk/sources/file_based/file_types/unstructured_parser.py +9 -8
  89. airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py +2 -1
  90. airbyte_cdk/sources/file_based/stream/concurrent/adapters.py +5 -4
  91. airbyte_cdk/sources/file_based/stream/concurrent/cursor/abstract_concurrent_file_based_cursor.py +1 -1
  92. airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_concurrent_cursor.py +1 -1
  93. airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_final_state_cursor.py +1 -1
  94. airbyte_cdk/sources/http_logger.py +1 -0
  95. airbyte_cdk/sources/streams/call_rate.py +1 -2
  96. airbyte_cdk/sources/streams/concurrent/abstract_stream.py +2 -1
  97. airbyte_cdk/sources/streams/concurrent/adapters.py +8 -4
  98. airbyte_cdk/sources/streams/concurrent/availability_strategy.py +2 -1
  99. airbyte_cdk/sources/streams/concurrent/cursor.py +30 -6
  100. airbyte_cdk/sources/streams/concurrent/partitions/partition.py +1 -1
  101. airbyte_cdk/sources/streams/concurrent/partitions/types.py +1 -1
  102. airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py +1 -1
  103. airbyte_cdk/sources/streams/core.py +2 -1
  104. airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py +2 -1
  105. airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py +1 -0
  106. airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py +1 -0
  107. airbyte_cdk/sources/streams/http/error_handlers/response_models.py +2 -1
  108. airbyte_cdk/sources/streams/http/http.py +3 -2
  109. airbyte_cdk/sources/streams/http/http_client.py +49 -2
  110. airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +2 -1
  111. airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py +1 -0
  112. airbyte_cdk/sources/types.py +14 -1
  113. airbyte_cdk/sources/utils/schema_helpers.py +3 -2
  114. airbyte_cdk/sql/secrets.py +2 -1
  115. airbyte_cdk/sql/shared/sql_processor.py +8 -6
  116. airbyte_cdk/test/entrypoint_wrapper.py +4 -3
  117. airbyte_cdk/test/mock_http/mocker.py +1 -0
  118. airbyte_cdk/utils/schema_inferrer.py +2 -1
  119. airbyte_cdk/utils/slice_hasher.py +1 -1
  120. airbyte_cdk/utils/traced_exception.py +2 -1
  121. {airbyte_cdk-6.7.0rc2.dist-info → airbyte_cdk-6.7.1.dist-info}/METADATA +11 -3
  122. {airbyte_cdk-6.7.0rc2.dist-info → airbyte_cdk-6.7.1.dist-info}/RECORD +125 -121
  123. airbyte_cdk-6.7.1.dist-info/entry_points.txt +3 -0
  124. airbyte_cdk/sources/streams/concurrent/partitions/record.py +0 -35
  125. {airbyte_cdk-6.7.0rc2.dist-info → airbyte_cdk-6.7.1.dist-info}/LICENSE.txt +0 -0
  126. {airbyte_cdk-6.7.0rc2.dist-info → airbyte_cdk-6.7.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1 @@
1
+ # Copyright (c) 2024 Airbyte, Inc., all rights reserved.
@@ -0,0 +1,6 @@
1
+ from airbyte_cdk.cli.source_declarative_manifest._run import run
2
+
3
+
4
+ __all__ = [
5
+ "run",
6
+ ]
@@ -0,0 +1,224 @@
1
+ # Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2
+ """Defines the `source-declarative-manifest` connector, which installs alongside CDK.
3
+
4
+ This file was originally imported from the dedicated connector directory, under the
5
+ `airbyte` monorepo.
6
+
7
+ Usage:
8
+
9
+ ```
10
+ pipx install airbyte-cdk
11
+ source-declarative-manifest --help
12
+ source-declarative-manifest spec
13
+ ...
14
+ ```
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import json
20
+ import pkgutil
21
+ import sys
22
+ import traceback
23
+ from collections.abc import Mapping
24
+ from datetime import datetime
25
+ from pathlib import Path
26
+ from typing import Any, cast
27
+
28
+ from orjson import orjson
29
+
30
+ from airbyte_cdk.entrypoint import AirbyteEntrypoint, launch
31
+ from airbyte_cdk.models import (
32
+ AirbyteErrorTraceMessage,
33
+ AirbyteMessage,
34
+ AirbyteMessageSerializer,
35
+ AirbyteStateMessage,
36
+ AirbyteTraceMessage,
37
+ ConfiguredAirbyteCatalog,
38
+ ConnectorSpecificationSerializer,
39
+ TraceType,
40
+ Type,
41
+ )
42
+ from airbyte_cdk.sources.declarative.concurrent_declarative_source import (
43
+ ConcurrentDeclarativeSource,
44
+ )
45
+ from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource
46
+ from airbyte_cdk.sources.source import TState
47
+
48
+
49
+ class SourceLocalYaml(YamlDeclarativeSource):
50
+ """
51
+ Declarative source defined by a yaml file in the local filesystem
52
+ """
53
+
54
+ def __init__(
55
+ self,
56
+ catalog: ConfiguredAirbyteCatalog | None,
57
+ config: Mapping[str, Any] | None,
58
+ state: TState,
59
+ **kwargs: Any,
60
+ ) -> None:
61
+ """
62
+ HACK!
63
+ Problem: YamlDeclarativeSource relies on the calling module name/path to find the yaml file.
64
+ Implication: If you call YamlDeclarativeSource directly it will look for the yaml file in the wrong place. (e.g. the airbyte-cdk package)
65
+ Solution: Subclass YamlDeclarativeSource from the same location as the manifest to load.
66
+
67
+ When can we remove this?
68
+ When the airbyte-cdk is updated to not rely on the calling module name/path to find the yaml file.
69
+ When all manifest connectors are updated to use the new airbyte-cdk.
70
+ When all manifest connectors are updated to use the source-declarative-manifest as the base image.
71
+ """
72
+ super().__init__(
73
+ catalog=catalog,
74
+ config=config,
75
+ state=state,
76
+ path_to_yaml="manifest.yaml",
77
+ )
78
+
79
+
80
+ def _is_local_manifest_command(args: list[str]) -> bool:
81
+ # Check for a local manifest.yaml file
82
+ return Path("/airbyte/integration_code/source_declarative_manifest/manifest.yaml").exists()
83
+
84
+
85
+ def handle_command(args: list[str]) -> None:
86
+ if _is_local_manifest_command(args):
87
+ handle_local_manifest_command(args)
88
+ else:
89
+ handle_remote_manifest_command(args)
90
+
91
+
92
+ def _get_local_yaml_source(args: list[str]) -> SourceLocalYaml:
93
+ try:
94
+ config, catalog, state = _parse_inputs_into_config_catalog_state(args)
95
+ return SourceLocalYaml(config=config, catalog=catalog, state=state)
96
+ except Exception as error:
97
+ print(
98
+ orjson.dumps(
99
+ AirbyteMessageSerializer.dump(
100
+ AirbyteMessage(
101
+ type=Type.TRACE,
102
+ trace=AirbyteTraceMessage(
103
+ type=TraceType.ERROR,
104
+ emitted_at=int(datetime.now().timestamp() * 1000),
105
+ error=AirbyteErrorTraceMessage(
106
+ message=f"Error starting the sync. This could be due to an invalid configuration or catalog. Please contact Support for assistance. Error: {error}",
107
+ stack_trace=traceback.format_exc(),
108
+ ),
109
+ ),
110
+ )
111
+ )
112
+ ).decode()
113
+ )
114
+ raise error
115
+
116
+
117
+ def handle_local_manifest_command(args: list[str]) -> None:
118
+ source = _get_local_yaml_source(args)
119
+ launch(
120
+ source=source,
121
+ args=args,
122
+ )
123
+
124
+
125
+ def handle_remote_manifest_command(args: list[str]) -> None:
126
+ """Overrides the spec command to return the generalized spec for the declarative manifest source.
127
+
128
+ This is different from a typical low-code, but built and published separately source built as a ManifestDeclarativeSource,
129
+ because that will have a spec method that returns the spec for that specific source. Other than spec,
130
+ the generalized connector behaves the same as any other, since the manifest is provided in the config.
131
+ """
132
+ if args[0] == "spec":
133
+ json_spec = pkgutil.get_data(
134
+ "airbyte_cdk.cli.source_declarative_manifest",
135
+ "spec.json",
136
+ )
137
+ if json_spec is None:
138
+ raise FileNotFoundError(
139
+ "Could not find `spec.json` file for source-declarative-manifest"
140
+ )
141
+
142
+ spec_obj = json.loads(json_spec)
143
+ spec = ConnectorSpecificationSerializer.load(spec_obj)
144
+
145
+ message = AirbyteMessage(type=Type.SPEC, spec=spec)
146
+ print(AirbyteEntrypoint.airbyte_message_to_string(message))
147
+ else:
148
+ source = create_declarative_source(args)
149
+ launch(
150
+ source=source,
151
+ args=args,
152
+ )
153
+
154
+
155
+ def create_declarative_source(args: list[str]) -> ConcurrentDeclarativeSource:
156
+ """Creates the source with the injected config.
157
+
158
+ This essentially does what other low-code sources do at build time, but at runtime,
159
+ with a user-provided manifest in the config. This better reflects what happens in the
160
+ connector builder.
161
+ """
162
+ try:
163
+ config, catalog, state = _parse_inputs_into_config_catalog_state(args)
164
+ if "__injected_declarative_manifest" not in config:
165
+ raise ValueError(
166
+ f"Invalid config: `__injected_declarative_manifest` should be provided at the root of the config but config only has keys {list(config.keys())}"
167
+ )
168
+ return ConcurrentDeclarativeSource(
169
+ config=config,
170
+ catalog=catalog,
171
+ state=state,
172
+ source_config=cast(dict[str, Any], config["__injected_declarative_manifest"]),
173
+ )
174
+ except Exception as error:
175
+ print(
176
+ orjson.dumps(
177
+ AirbyteMessageSerializer.dump(
178
+ AirbyteMessage(
179
+ type=Type.TRACE,
180
+ trace=AirbyteTraceMessage(
181
+ type=TraceType.ERROR,
182
+ emitted_at=int(datetime.now().timestamp() * 1000),
183
+ error=AirbyteErrorTraceMessage(
184
+ message=f"Error starting the sync. This could be due to an invalid configuration or catalog. Please contact Support for assistance. Error: {error}",
185
+ stack_trace=traceback.format_exc(),
186
+ ),
187
+ ),
188
+ )
189
+ )
190
+ ).decode()
191
+ )
192
+ raise error
193
+
194
+
195
+ def _parse_inputs_into_config_catalog_state(
196
+ args: list[str],
197
+ ) -> tuple[
198
+ Mapping[str, Any] | None,
199
+ ConfiguredAirbyteCatalog | None,
200
+ list[AirbyteStateMessage],
201
+ ]:
202
+ parsed_args = AirbyteEntrypoint.parse_args(args)
203
+ config = (
204
+ ConcurrentDeclarativeSource.read_config(parsed_args.config)
205
+ if hasattr(parsed_args, "config")
206
+ else None
207
+ )
208
+ catalog = (
209
+ ConcurrentDeclarativeSource.read_catalog(parsed_args.catalog)
210
+ if hasattr(parsed_args, "catalog")
211
+ else None
212
+ )
213
+ state = (
214
+ ConcurrentDeclarativeSource.read_state(parsed_args.state)
215
+ if hasattr(parsed_args, "state")
216
+ else []
217
+ )
218
+
219
+ return config, catalog, state
220
+
221
+
222
+ def run() -> None:
223
+ args: list[str] = sys.argv[1:]
224
+ handle_command(args)
@@ -0,0 +1,17 @@
1
+ {
2
+ "documentationUrl": "https://docs.airbyte.com/integrations/sources/low-code",
3
+ "connectionSpecification": {
4
+ "$schema": "http://json-schema.org/draft-07/schema#",
5
+ "title": "Low-code source spec",
6
+ "type": "object",
7
+ "required": ["__injected_declarative_manifest"],
8
+ "additionalProperties": true,
9
+ "properties": {
10
+ "__injected_declarative_manifest": {
11
+ "title": "Low-code manifest",
12
+ "type": "object",
13
+ "description": "The low-code manifest that defines the components of the source."
14
+ }
15
+ }
16
+ }
17
+ }
@@ -10,6 +10,8 @@ import time
10
10
  from copy import copy
11
11
  from typing import Any, List, MutableMapping
12
12
 
13
+ from orjson import orjson
14
+
13
15
  from airbyte_cdk.models import (
14
16
  AirbyteControlConnectorConfigMessage,
15
17
  AirbyteControlMessage,
@@ -18,7 +20,6 @@ from airbyte_cdk.models import (
18
20
  OrchestratorType,
19
21
  Type,
20
22
  )
21
- from orjson import orjson
22
23
 
23
24
 
24
25
  class ObservedDict(dict): # type: ignore # disallow_any_generics is set to True, and dict is equivalent to dict[Any]
airbyte_cdk/connector.py CHANGED
@@ -11,6 +11,7 @@ from abc import ABC, abstractmethod
11
11
  from typing import Any, Generic, Mapping, Optional, Protocol, TypeVar
12
12
 
13
13
  import yaml
14
+
14
15
  from airbyte_cdk.models import (
15
16
  AirbyteConnectionStatus,
16
17
  ConnectorSpecification,
@@ -12,8 +12,8 @@ from airbyte_cdk.models import (
12
12
  AirbyteRecordMessage,
13
13
  AirbyteStateMessage,
14
14
  ConfiguredAirbyteCatalog,
15
+ Type,
15
16
  )
16
- from airbyte_cdk.models import Type
17
17
  from airbyte_cdk.models import Type as MessageType
18
18
  from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
19
19
  from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
@@ -6,6 +6,8 @@
6
6
  import sys
7
7
  from typing import Any, List, Mapping, Optional, Tuple
8
8
 
9
+ from orjson import orjson
10
+
9
11
  from airbyte_cdk.connector import BaseConnector
10
12
  from airbyte_cdk.connector_builder.connector_builder_handler import (
11
13
  TestReadLimits,
@@ -25,7 +27,6 @@ from airbyte_cdk.models import (
25
27
  from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
26
28
  from airbyte_cdk.sources.source import Source
27
29
  from airbyte_cdk.utils.traced_exception import AirbyteTracedException
28
- from orjson import orjson
29
30
 
30
31
 
31
32
  def get_config_and_catalog_from_args(
@@ -9,6 +9,8 @@ import sys
9
9
  from abc import ABC, abstractmethod
10
10
  from typing import Any, Iterable, List, Mapping
11
11
 
12
+ from orjson import orjson
13
+
12
14
  from airbyte_cdk.connector import Connector
13
15
  from airbyte_cdk.exception_handler import init_uncaught_exception_handler
14
16
  from airbyte_cdk.models import (
@@ -20,7 +22,6 @@ from airbyte_cdk.models import (
20
22
  )
21
23
  from airbyte_cdk.sources.utils.schema_helpers import check_config_against_spec_or_exit
22
24
  from airbyte_cdk.utils.traced_exception import AirbyteTracedException
23
- from orjson import orjson
24
25
 
25
26
  logger = logging.getLogger("airbyte")
26
27
 
@@ -5,9 +5,10 @@
5
5
  from typing import Any, Dict, List, Literal, Optional, Union
6
6
 
7
7
  import dpath
8
+ from pydantic.v1 import BaseModel, Field
9
+
8
10
  from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig
9
11
  from airbyte_cdk.utils.spec_schema_transformations import resolve_refs
10
- from pydantic.v1 import BaseModel, Field
11
12
 
12
13
 
13
14
  class SeparatorSplitterConfigModel(BaseModel):
@@ -8,6 +8,10 @@ from dataclasses import dataclass
8
8
  from typing import Any, Dict, List, Mapping, Optional, Tuple
9
9
 
10
10
  import dpath
11
+ from langchain.text_splitter import Language, RecursiveCharacterTextSplitter
12
+ from langchain.utils import stringify_dict
13
+ from langchain_core.documents.base import Document
14
+
11
15
  from airbyte_cdk.destinations.vector_db_based.config import (
12
16
  ProcessingConfigModel,
13
17
  SeparatorSplitterConfigModel,
@@ -21,9 +25,6 @@ from airbyte_cdk.models import (
21
25
  DestinationSyncMode,
22
26
  )
23
27
  from airbyte_cdk.utils.traced_exception import AirbyteTracedException, FailureType
24
- from langchain.text_splitter import Language, RecursiveCharacterTextSplitter
25
- from langchain.utils import stringify_dict
26
- from langchain_core.documents.base import Document
27
28
 
28
29
  METADATA_STREAM_FIELD = "_ab_stream"
29
30
  METADATA_RECORD_ID_FIELD = "_ab_record_id"
@@ -7,6 +7,11 @@ from abc import ABC, abstractmethod
7
7
  from dataclasses import dataclass
8
8
  from typing import List, Optional, Union, cast
9
9
 
10
+ from langchain.embeddings.cohere import CohereEmbeddings
11
+ from langchain.embeddings.fake import FakeEmbeddings
12
+ from langchain.embeddings.localai import LocalAIEmbeddings
13
+ from langchain.embeddings.openai import OpenAIEmbeddings
14
+
10
15
  from airbyte_cdk.destinations.vector_db_based.config import (
11
16
  AzureOpenAIEmbeddingConfigModel,
12
17
  CohereEmbeddingConfigModel,
@@ -19,10 +24,6 @@ from airbyte_cdk.destinations.vector_db_based.config import (
19
24
  from airbyte_cdk.destinations.vector_db_based.utils import create_chunks, format_exception
20
25
  from airbyte_cdk.models import AirbyteRecordMessage
21
26
  from airbyte_cdk.utils.traced_exception import AirbyteTracedException, FailureType
22
- from langchain.embeddings.cohere import CohereEmbeddings
23
- from langchain.embeddings.fake import FakeEmbeddings
24
- from langchain.embeddings.localai import LocalAIEmbeddings
25
- from langchain.embeddings.openai import OpenAIEmbeddings
26
27
 
27
28
 
28
29
  @dataclass
airbyte_cdk/entrypoint.py CHANGED
@@ -16,6 +16,9 @@ from typing import Any, DefaultDict, Iterable, List, Mapping, Optional
16
16
  from urllib.parse import urlparse
17
17
 
18
18
  import requests
19
+ from orjson import orjson
20
+ from requests import PreparedRequest, Response, Session
21
+
19
22
  from airbyte_cdk.connector import TConfig
20
23
  from airbyte_cdk.exception_handler import init_uncaught_exception_handler
21
24
  from airbyte_cdk.logger import init_logger
@@ -38,8 +41,6 @@ from airbyte_cdk.utils import is_cloud_environment, message_utils
38
41
  from airbyte_cdk.utils.airbyte_secrets_utils import get_secrets, update_secrets
39
42
  from airbyte_cdk.utils.constants import ENV_REQUEST_CACHE_PATH
40
43
  from airbyte_cdk.utils.traced_exception import AirbyteTracedException
41
- from orjson import orjson
42
- from requests import PreparedRequest, Response, Session
43
44
 
44
45
  logger = init_logger("airbyte")
45
46
 
airbyte_cdk/logger.py CHANGED
@@ -7,6 +7,8 @@ import logging
7
7
  import logging.config
8
8
  from typing import Any, Callable, Mapping, Optional, Tuple
9
9
 
10
+ from orjson import orjson
11
+
10
12
  from airbyte_cdk.models import (
11
13
  AirbyteLogMessage,
12
14
  AirbyteMessage,
@@ -15,7 +17,6 @@ from airbyte_cdk.models import (
15
17
  Type,
16
18
  )
17
19
  from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets
18
- from orjson import orjson
19
20
 
20
21
  LOGGING_CONFIG = {
21
22
  "version": 1,
@@ -39,7 +39,9 @@ from .airbyte_protocol import (
39
39
  FailureType,
40
40
  Level,
41
41
  OAuthConfigSpecification,
42
+ OauthConnectorInputSpecification,
42
43
  OrchestratorType,
44
+ State,
43
45
  Status,
44
46
  StreamDescriptor,
45
47
  SyncMode,
@@ -5,10 +5,11 @@
5
5
  from dataclasses import InitVar, dataclass
6
6
  from typing import Annotated, Any, Dict, List, Mapping, Optional, Union
7
7
 
8
- from airbyte_cdk.models.file_transfer_record_message import AirbyteFileTransferRecordMessage
9
8
  from airbyte_protocol_dataclasses.models import * # noqa: F403 # Allow '*'
10
9
  from serpyco_rs.metadata import Alias
11
10
 
11
+ from airbyte_cdk.models.file_transfer_record_message import AirbyteFileTransferRecordMessage
12
+
12
13
  # ruff: noqa: F405 # ignore fuzzy import issues with 'import *'
13
14
 
14
15
 
@@ -17,8 +17,8 @@ from airbyte_cdk.sources.streams.concurrent.abstract_stream import AbstractStrea
17
17
  from airbyte_cdk.sources.streams.concurrent.partition_enqueuer import PartitionEnqueuer
18
18
  from airbyte_cdk.sources.streams.concurrent.partition_reader import PartitionReader
19
19
  from airbyte_cdk.sources.streams.concurrent.partitions.partition import Partition
20
- from airbyte_cdk.sources.streams.concurrent.partitions.record import Record
21
20
  from airbyte_cdk.sources.streams.concurrent.partitions.types import PartitionCompleteSentinel
21
+ from airbyte_cdk.sources.types import Record
22
22
  from airbyte_cdk.sources.utils.record_helper import stream_data_to_airbyte_message
23
23
  from airbyte_cdk.sources.utils.slice_logger import SliceLogger
24
24
  from airbyte_cdk.utils import AirbyteTracedException
@@ -147,11 +147,11 @@ class ConcurrentReadProcessor:
147
147
  # AbstractStreams are expected to return data as they are expected.
148
148
  # Any transformation on the data should be done before reaching this point
149
149
  message = stream_data_to_airbyte_message(
150
- stream_name=record.partition.stream_name(),
150
+ stream_name=record.stream_name,
151
151
  data_or_message=record.data,
152
152
  is_file_transfer_message=record.is_file_transfer_message,
153
153
  )
154
- stream = self._stream_name_to_instance[record.partition.stream_name()]
154
+ stream = self._stream_name_to_instance[record.stream_name]
155
155
 
156
156
  if message.type == MessageType.RECORD:
157
157
  if self._record_counter[stream.name] == 0:
@@ -18,11 +18,11 @@ from airbyte_cdk.sources.streams.concurrent.abstract_stream import AbstractStrea
18
18
  from airbyte_cdk.sources.streams.concurrent.partition_enqueuer import PartitionEnqueuer
19
19
  from airbyte_cdk.sources.streams.concurrent.partition_reader import PartitionReader
20
20
  from airbyte_cdk.sources.streams.concurrent.partitions.partition import Partition
21
- from airbyte_cdk.sources.streams.concurrent.partitions.record import Record
22
21
  from airbyte_cdk.sources.streams.concurrent.partitions.types import (
23
22
  PartitionCompleteSentinel,
24
23
  QueueItem,
25
24
  )
25
+ from airbyte_cdk.sources.types import Record
26
26
  from airbyte_cdk.sources.utils.slice_logger import DebugSliceLogger, SliceLogger
27
27
 
28
28
 
@@ -4,9 +4,10 @@
4
4
 
5
5
  from typing import Any, Dict
6
6
 
7
- from airbyte_cdk.sources.utils.schema_helpers import expand_refs, rename_key
8
7
  from pydantic.v1 import BaseModel
9
8
 
9
+ from airbyte_cdk.sources.utils.schema_helpers import expand_refs, rename_key
10
+
10
11
 
11
12
  class BaseConfig(BaseModel):
12
13
  """Base class for connector spec, adds the following behaviour:
@@ -8,6 +8,7 @@ from datetime import datetime
8
8
  from typing import Any, Mapping, Optional, Union
9
9
 
10
10
  import jwt
11
+
11
12
  from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
12
13
  from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean
13
14
  from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping
@@ -6,6 +6,7 @@ from dataclasses import InitVar, dataclass, field
6
6
  from typing import Any, List, Mapping, Optional, Union
7
7
 
8
8
  import pendulum
9
+
9
10
  from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
10
11
  from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping
11
12
  from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
@@ -6,6 +6,7 @@ from dataclasses import dataclass
6
6
  from typing import Any, List, Mapping
7
7
 
8
8
  import dpath
9
+
9
10
  from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
10
11
 
11
12
 
@@ -8,6 +8,8 @@ from dataclasses import InitVar, dataclass
8
8
  from typing import Any, Mapping, Union
9
9
 
10
10
  import requests
11
+ from cachetools import TTLCache, cached
12
+
11
13
  from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
12
14
  from airbyte_cdk.sources.declarative.auth.token_provider import TokenProvider
13
15
  from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
@@ -16,7 +18,6 @@ from airbyte_cdk.sources.declarative.requesters.request_option import (
16
18
  RequestOptionType,
17
19
  )
18
20
  from airbyte_cdk.sources.types import Config
19
- from cachetools import TTLCache, cached
20
21
 
21
22
 
22
23
  @dataclass
@@ -10,6 +10,9 @@ from typing import Any, List, Mapping, Optional, Union
10
10
 
11
11
  import dpath
12
12
  import pendulum
13
+ from isodate import Duration
14
+ from pendulum import DateTime
15
+
13
16
  from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
14
17
  from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder
15
18
  from airbyte_cdk.sources.declarative.exceptions import ReadException
@@ -18,8 +21,6 @@ from airbyte_cdk.sources.declarative.requesters.requester import Requester
18
21
  from airbyte_cdk.sources.http_logger import format_http_message
19
22
  from airbyte_cdk.sources.message import MessageRepository, NoopMessageRepository
20
23
  from airbyte_cdk.sources.types import Config
21
- from isodate import Duration
22
- from pendulum import DateTime
23
24
 
24
25
 
25
26
  class TokenProvider: