airbyte-cdk 6.9.1.dev2__py3-none-any.whl → 6.9.1rc2__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 (20) hide show
  1. airbyte_cdk/sources/declarative/concurrent_declarative_source.py +25 -31
  2. airbyte_cdk/sources/declarative/datetime/datetime_parser.py +4 -4
  3. airbyte_cdk/sources/declarative/declarative_component_schema.yaml +100 -2
  4. airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py +1 -1
  5. airbyte_cdk/sources/declarative/manifest_declarative_source.py +53 -2
  6. airbyte_cdk/sources/declarative/models/declarative_component_schema.py +95 -2
  7. airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py +6 -0
  8. airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +95 -21
  9. airbyte_cdk/sources/declarative/partition_routers/__init__.py +2 -1
  10. airbyte_cdk/sources/declarative/resolvers/__init__.py +13 -0
  11. airbyte_cdk/sources/declarative/resolvers/components_resolver.py +55 -0
  12. airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py +106 -0
  13. airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py +2 -2
  14. airbyte_cdk-6.9.1rc2.dist-info/METADATA +108 -0
  15. {airbyte_cdk-6.9.1.dev2.dist-info → airbyte_cdk-6.9.1rc2.dist-info}/RECORD +18 -16
  16. airbyte_cdk/test/utils/manifest_only_fixtures.py +0 -79
  17. airbyte_cdk-6.9.1.dev2.dist-info/METADATA +0 -306
  18. {airbyte_cdk-6.9.1.dev2.dist-info → airbyte_cdk-6.9.1rc2.dist-info}/LICENSE.txt +0 -0
  19. {airbyte_cdk-6.9.1.dev2.dist-info → airbyte_cdk-6.9.1rc2.dist-info}/WHEEL +0 -0
  20. {airbyte_cdk-6.9.1.dev2.dist-info → airbyte_cdk-6.9.1rc2.dist-info}/entry_points.txt +0 -0
@@ -1,79 +0,0 @@
1
- # Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2
-
3
-
4
- import importlib.util
5
- from pathlib import Path
6
- from types import ModuleType
7
- from typing import Optional
8
-
9
- import pytest
10
-
11
- # The following fixtures are used to load a manifest-only connector's components module and manifest file.
12
- # They can be accessed from any test file in the connector's unit_tests directory by importing them as follows:
13
-
14
- # from airbyte_cdk.test.utils.manifest_only_fixtures import components_module, connector_dir, manifest_path
15
-
16
- # individual components can then be referenced as: components_module.<CustomComponentClass>
17
-
18
-
19
- import os
20
- from typing import Any, Optional
21
- import pytest
22
- from pathlib import Path
23
- import importlib.util
24
- from types import ModuleType
25
-
26
-
27
- @pytest.fixture(scope="session")
28
- def connector_dir(request: pytest.FixtureRequest) -> Path:
29
- """Return the connector's root directory."""
30
- print("\n=== CDK Path Resolution Debug ===")
31
- print(f"Config root path: {request.config.rootpath}")
32
- print(f"Invocation dir: {request.config.invocation_params.dir}")
33
- print(f"Current working dir: {os.getcwd()}")
34
- print(f"Environment variables: {dict(os.environ)}")
35
- print(f"Directory contents: {os.listdir(os.getcwd())}")
36
- print("==============================\n")
37
-
38
- path = Path(request.config.invocation_params.dir)
39
- resolved_path = path.parent
40
- print(f"Resolved connector dir: {resolved_path}")
41
- print(f"Resolved dir contents: {os.listdir(resolved_path) if resolved_path.exists() else 'Directory not found'}")
42
-
43
- return resolved_path
44
-
45
-
46
- @pytest.fixture(scope="session")
47
- def components_module(connector_dir: Path) -> Optional[ModuleType]:
48
- print("\n=== Components Module Debug ===")
49
- components_path = connector_dir / "components.py"
50
- print(f"Looking for components.py at: {components_path}")
51
- print(f"File exists: {components_path.exists()}")
52
-
53
- if not components_path.exists():
54
- print("components.py not found")
55
- return None
56
-
57
- spec = importlib.util.spec_from_file_location("components", components_path)
58
- print(f"Import spec created: {spec is not None}")
59
-
60
- if spec is None:
61
- return None
62
-
63
- module = importlib.util.module_from_spec(spec)
64
- print(f"Module created: {module is not None}")
65
-
66
- if spec.loader is None:
67
- return None
68
-
69
- spec.loader.exec_module(module)
70
- print("Module loaded successfully")
71
- print("===========================\n")
72
-
73
- return module
74
-
75
-
76
- @pytest.fixture(scope="session")
77
- def manifest_path(connector_dir: Path) -> Path:
78
- """Return the path to the connector's manifest file."""
79
- return connector_dir / "manifest.yaml"
@@ -1,306 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: airbyte-cdk
3
- Version: 6.9.1.dev2
4
- Summary: A framework for writing Airbyte Connectors.
5
- Home-page: https://airbyte.com
6
- License: MIT
7
- Keywords: airbyte,connector-development-kit,cdk
8
- Author: Airbyte
9
- Author-email: contact@airbyte.io
10
- Requires-Python: >=3.10,<3.13
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Topic :: Scientific/Engineering
19
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
- Provides-Extra: file-based
21
- Provides-Extra: sphinx-docs
22
- Provides-Extra: sql
23
- Provides-Extra: vector-db-based
24
- Requires-Dist: Jinja2 (>=3.1.2,<3.2.0)
25
- Requires-Dist: PyYAML (>=6.0.1,<7.0.0)
26
- Requires-Dist: Sphinx (>=4.2,<4.3) ; extra == "sphinx-docs"
27
- Requires-Dist: airbyte-protocol-models-dataclasses (>=0.14,<0.15)
28
- Requires-Dist: avro (>=1.11.2,<1.12.0) ; extra == "file-based"
29
- Requires-Dist: backoff
30
- Requires-Dist: cachetools
31
- Requires-Dist: cohere (==4.21) ; extra == "vector-db-based"
32
- Requires-Dist: cryptography (>=42.0.5,<44.0.0)
33
- Requires-Dist: dpath (>=2.1.6,<3.0.0)
34
- Requires-Dist: dunamai (>=1.22.0,<2.0.0)
35
- Requires-Dist: fastavro (>=1.8.0,<1.9.0) ; extra == "file-based"
36
- Requires-Dist: genson (==1.3.0)
37
- Requires-Dist: isodate (>=0.6.1,<0.7.0)
38
- Requires-Dist: jsonref (>=0.2,<0.3)
39
- Requires-Dist: jsonschema (>=4.17.3,<4.18.0)
40
- Requires-Dist: langchain (==0.1.16) ; extra == "vector-db-based"
41
- Requires-Dist: langchain_core (==0.1.42)
42
- Requires-Dist: markdown ; extra == "file-based"
43
- Requires-Dist: nltk (==3.9.1)
44
- Requires-Dist: numpy (<2)
45
- Requires-Dist: openai[embeddings] (==0.27.9) ; extra == "vector-db-based"
46
- Requires-Dist: orjson (>=3.10.7,<4.0.0)
47
- Requires-Dist: pandas (==2.2.2)
48
- Requires-Dist: pdf2image (==1.16.3) ; extra == "file-based"
49
- Requires-Dist: pdfminer.six (==20221105) ; extra == "file-based"
50
- Requires-Dist: pendulum (<3.0.0)
51
- Requires-Dist: psutil (==6.1.0)
52
- Requires-Dist: pyarrow (>=15.0.0,<15.1.0) ; extra == "file-based"
53
- Requires-Dist: pydantic (>=2.7,<3.0)
54
- Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
55
- Requires-Dist: pyrate-limiter (>=3.1.0,<3.2.0)
56
- Requires-Dist: pytesseract (==0.3.10) ; extra == "file-based"
57
- Requires-Dist: python-calamine (==0.2.3) ; extra == "file-based"
58
- Requires-Dist: python-dateutil
59
- Requires-Dist: python-snappy (==0.7.3) ; extra == "file-based"
60
- Requires-Dist: python-ulid (>=3.0.0,<4.0.0)
61
- Requires-Dist: pytz (==2024.1)
62
- Requires-Dist: rapidfuzz (>=3.10.1,<4.0.0)
63
- Requires-Dist: requests
64
- Requires-Dist: requests_cache
65
- Requires-Dist: serpyco-rs (>=1.10.2,<2.0.0)
66
- Requires-Dist: sphinx-rtd-theme (>=1.0,<1.1) ; extra == "sphinx-docs"
67
- Requires-Dist: sqlalchemy (>=2.0,<3.0,!=2.0.36) ; extra == "sql"
68
- Requires-Dist: tiktoken (==0.8.0) ; extra == "vector-db-based"
69
- Requires-Dist: unstructured.pytesseract (>=0.3.12) ; extra == "file-based"
70
- Requires-Dist: unstructured[docx,pptx] (==0.10.27) ; extra == "file-based"
71
- Requires-Dist: wcmatch (==10.0)
72
- Requires-Dist: xmltodict (>=0.13.0,<0.14.0)
73
- Project-URL: Documentation, https://docs.airbyte.io/
74
- Project-URL: Repository, https://github.com/airbytehq/airbyte-python-cdk
75
- Description-Content-Type: text/markdown
76
-
77
- # Airbyte Python CDK and Low-Code CDK
78
-
79
- Airbyte Python CDK is a framework for building Airbyte API Source Connectors. It provides a set of
80
- classes and helpers that make it easy to build a connector against an HTTP API (REST, GraphQL, etc),
81
- or a generic Python source connector.
82
-
83
- ## Usage
84
-
85
- If you're looking to build a connector, we highly recommend that you
86
- [start with the Connector Builder](https://docs.airbyte.com/connector-development/connector-builder-ui/overview).
87
- It should be enough for 90% connectors out there. For more flexible and complex connectors, use the
88
- [low-code CDK and `SourceDeclarativeManifest`](https://docs.airbyte.com/connector-development/config-based/low-code-cdk-overview).
89
-
90
- If that doesn't work, then consider building on top of the
91
- [lower-level Python CDK itself](https://docs.airbyte.com/connector-development/cdk-python/).
92
-
93
- ### Quick Start
94
-
95
- To get started on a Python CDK based connector or a low-code connector, you can generate a connector
96
- project from a template:
97
-
98
- ```bash
99
- # from the repo root
100
- cd airbyte-integrations/connector-templates/generator
101
- ./generate.sh
102
- ```
103
-
104
- ### Example Connectors
105
-
106
- **HTTP Connectors**:
107
-
108
- - [Stripe](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-stripe/)
109
- - [Salesforce](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-salesforce/)
110
-
111
- **Python connectors using the bare-bones `Source` abstraction**:
112
-
113
- - [Google Sheets](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-google-sheets/google_sheets_source/google_sheets_source.py)
114
-
115
- This will generate a project with a type and a name of your choice and put it in
116
- `airbyte-integrations/connectors`. Open the directory with your connector in an editor and follow
117
- the `TODO` items.
118
-
119
- ## Python CDK Overview
120
-
121
- Airbyte CDK code is within `airbyte_cdk` directory. Here's a high level overview of what's inside:
122
-
123
- - `connector_builder`. Internal wrapper that helps the Connector Builder platform run a declarative
124
- manifest (low-code connector). You should not use this code directly. If you need to run a
125
- `SourceDeclarativeManifest`, take a look at
126
- [`source-declarative-manifest`](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-declarative-manifest)
127
- connector implementation instead.
128
- - `destinations`. Basic Destination connector support! If you're building a Destination connector in
129
- Python, try that. Some of our vector DB destinations like `destination-pinecone` are using that
130
- code.
131
- - `models` expose `airbyte_protocol.models` as a part of `airbyte_cdk` package.
132
- - `sources/concurrent_source` is the Concurrent CDK implementation. It supports reading data from
133
- streams concurrently per slice / partition, useful for connectors with high throughput and high
134
- number of records.
135
- - `sources/declarative` is the low-code CDK. It works on top of Airbyte Python CDK, but provides a
136
- declarative manifest language to define streams, operations, etc. This makes it easier to build
137
- connectors without writing Python code.
138
- - `sources/file_based` is the CDK for file-based sources. Examples include S3, Azure, GCS, etc.
139
-
140
- ## Contributing
141
-
142
- Thank you for being interested in contributing to Airbyte Python CDK! Here are some guidelines to
143
- get you started:
144
-
145
- - We adhere to the [code of conduct](/CODE_OF_CONDUCT.md).
146
- - You can contribute by reporting bugs, posting github discussions, opening issues, improving
147
- [documentation](/docs/), and submitting pull requests with bugfixes and new features alike.
148
- - If you're changing the code, please add unit tests for your change.
149
- - When submitting issues or PRs, please add a small reproduction project. Using the changes in your
150
- connector and providing that connector code as an example (or a satellite PR) helps!
151
-
152
- ### First time setup
153
-
154
- Install the project dependencies and development tools:
155
-
156
- ```bash
157
- poetry install --all-extras
158
- ```
159
-
160
- Installing all extras is required to run the full suite of unit tests.
161
-
162
- #### Running tests locally
163
-
164
- - Iterate on the CDK code locally
165
- - Run tests via `poetry run poe unit-test-with-cov`, or `python -m pytest -s unit_tests` if you want
166
- to pass pytest options.
167
- - Run `poetry run poe check-local` to lint all code, type-check modified code, and run unit tests
168
- with coverage in one command.
169
-
170
- To see all available scripts, run `poetry run poe`.
171
-
172
- #### Formatting the code
173
-
174
- - Iterate on the CDK code locally
175
- - Run `poetry run ruff format` to format your changes.
176
-
177
- To see all available `ruff` options, run `poetry run ruff`.
178
-
179
- ##### Autogenerated files
180
-
181
- Low-code CDK models are generated from `sources/declarative/declarative_component_schema.yaml`. If
182
- the iteration you are working on includes changes to the models or the connector generator, you
183
- might want to regenerate them. In order to do that, you can run:
184
-
185
- ```bash
186
- poetry run poe build
187
- ```
188
-
189
- This will generate the code generator docker image and the component manifest files based on the
190
- schemas and templates.
191
-
192
- #### Testing
193
-
194
- All tests are located in the `unit_tests` directory. Run `poetry run poe unit-test-with-cov` to run
195
- them. This also presents a test coverage report. For faster iteration with no coverage report and
196
- more options, `python -m pytest -s unit_tests` is a good place to start.
197
-
198
- #### Building and testing a connector with your local CDK
199
-
200
- When developing a new feature in the CDK, you may find it helpful to run a connector that uses that
201
- new feature. You can test this in one of two ways:
202
-
203
- - Running a connector locally
204
- - Building and running a source via Docker
205
-
206
- ##### Installing your local CDK into a local Python connector
207
-
208
- Open the connector's `pyproject.toml` file and replace the line with `airbyte_cdk` with the
209
- following:
210
-
211
- ```toml
212
- airbyte_cdk = { path = "../../../airbyte-cdk/python/airbyte_cdk", develop = true }
213
- ```
214
-
215
- Then, running `poetry update` should reinstall `airbyte_cdk` from your local working directory.
216
-
217
- ##### Building a Python connector in Docker with your local CDK installed
218
-
219
- _Pre-requisite: Install the
220
- [`airbyte-ci` CLI](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)_
221
-
222
- You can build your connector image with the local CDK using
223
-
224
- ```bash
225
- # from the airbytehq/airbyte base directory
226
- airbyte-ci connectors --use-local-cdk --name=<CONNECTOR> build
227
- ```
228
-
229
- Note that the local CDK is injected at build time, so if you make changes, you will have to run the
230
- build command again to see them reflected.
231
-
232
- ##### Running Connector Acceptance Tests for a single connector in Docker with your local CDK installed
233
-
234
- _Pre-requisite: Install the
235
- [`airbyte-ci` CLI](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)_
236
-
237
- To run acceptance tests for a single connectors using the local CDK, from the connector directory,
238
- run
239
-
240
- ```bash
241
- airbyte-ci connectors --use-local-cdk --name=<CONNECTOR> test
242
- ```
243
-
244
- #### When you don't have access to the API
245
-
246
- There may be a time when you do not have access to the API (either because you don't have the
247
- credentials, network access, etc...) You will probably still want to do end-to-end testing at least
248
- once. In order to do so, you can emulate the server you would be reaching using a server stubbing
249
- tool.
250
-
251
- For example, using [mockserver](https://www.mock-server.com/), you can set up an expectation file
252
- like this:
253
-
254
- ```json
255
- {
256
- "httpRequest": {
257
- "method": "GET",
258
- "path": "/data"
259
- },
260
- "httpResponse": {
261
- "body": "{\"data\": [{\"record_key\": 1}, {\"record_key\": 2}]}"
262
- }
263
- }
264
- ```
265
-
266
- Assuming this file has been created at `secrets/mock_server_config/expectations.json`, running the
267
- following command will allow to match any requests on path `/data` to return the response defined in
268
- the expectation file:
269
-
270
- ```bash
271
- docker run -d --rm -v $(pwd)/secrets/mock_server_config:/config -p 8113:8113 --env MOCKSERVER_LOG_LEVEL=TRACE --env MOCKSERVER_SERVER_PORT=8113 --env MOCKSERVER_WATCH_INITIALIZATION_JSON=true --env MOCKSERVER_PERSISTED_EXPECTATIONS_PATH=/config/expectations.json --env MOCKSERVER_INITIALIZATION_JSON_PATH=/config/expectations.json mockserver/mockserver:5.15.0
272
- ```
273
-
274
- HTTP requests to `localhost:8113/data` should now return the body defined in the expectations file.
275
- To test this, the implementer either has to change the code which defines the base URL for Python
276
- source or update the `url_base` from low-code. With the Connector Builder running in docker, you
277
- will have to use domain `host.docker.internal` instead of `localhost` as the requests are executed
278
- within docker.
279
-
280
- #### Publishing a new version to PyPi
281
-
282
- Python CDK has a
283
- [GitHub workflow](https://github.com/airbytehq/airbyte/actions/workflows/publish-cdk-command-manually.yml)
284
- that manages the CDK changelog, making a new release for `airbyte_cdk`, publishing it to PyPI, and
285
- then making a commit to update (and subsequently auto-release)
286
- [`source-declarative-m anifest`](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-declarative-manifest)
287
- and Connector Builder (in the platform repository).
288
-
289
- > [!Note]: The workflow will handle the `CHANGELOG.md` entry for you. You should not add changelog
290
- > lines in your PRs to the CDK itself.
291
-
292
- > [!Warning]: The workflow bumps version on it's own, please don't change the CDK version in
293
- > `pyproject.toml` manually.
294
-
295
- 1. You only trigger the release workflow once all the PRs that you want to be included are already
296
- merged into the `master` branch.
297
- 2. The
298
- [`Publish CDK Manually`](https://github.com/airbytehq/airbyte/actions/workflows/publish-cdk-command-manually.yml)
299
- workflow from master using `release-type=major|manor|patch` and setting the changelog message.
300
- 3. When the workflow runs, it will commit a new version directly to master branch.
301
- 4. The workflow will bump the version of `source-declarative-manifest` according to the
302
- `release-type` of the CDK, then commit these changes back to master. The commit to master will
303
- kick off a publish of the new version of `source-declarative-manifest`.
304
- 5. The workflow will also add a pull request to `airbyte-platform-internal` repo to bump the
305
- dependency in Connector Builder.
306
-