### Install Manifest Server with uv Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Install the manifest server as an extra dependency using uv. ```bash uv pip install 'airbyte-cdk[manifest-server]' ``` -------------------------------- ### Install Manifest Server with Poetry Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Install the manifest server as an extra dependency using Poetry. ```bash poetry install --extras manifest-server ``` -------------------------------- ### Install airbyte-cdk with pipx Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/cli/source_declarative_manifest/README.md Installs the airbyte-cdk library globally using pipx for command-line access. ```bash pipx install airbyte-cdk ``` -------------------------------- ### Install Manifest Server with Pip Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Install the manifest server as an extra dependency using pip. ```bash pip install airbyte-cdk[manifest-server] ``` -------------------------------- ### Start Manifest Server Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Start the manifest server on the default port 8000 or a specified port. ```bash manifest-server start ``` ```bash manifest-server start --port 8080 ``` -------------------------------- ### Start Manifest Server using Python module Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Alternative method to start the manifest server using the Python module. ```bash python -m airbyte_cdk.manifest_server.cli.run start ``` -------------------------------- ### Install airbyte-cdk in a local virtual environment Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/cli/source_declarative_manifest/README.md Installs the airbyte-cdk library within a local virtual environment for development purposes. This involves creating a virtual environment, activating it, and then installing the package in editable mode. ```bash python -m venv .venv source .venv/bin/activate pip install -e . ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Installs all project dependencies, including optional extras required for running the full suite of unit tests. ```bash poetry install --all-extras ``` -------------------------------- ### Install Airbyte CDK with Vector DB Support Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/destinations/vector_db_based/README.md Install the Airbyte CDK with the necessary extras for vector database functionality. ```bash pip install airbyte-cdk[vector-db-based] ``` -------------------------------- ### Run Manifest Server with Datadog Tracing Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Start the manifest server with Datadog tracing enabled by setting the DD_ENABLED environment variable. ```bash DD_ENABLED=true manifest-server start ``` -------------------------------- ### Install Tesseract OCR and Poppler on Ubuntu Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/sources/file_based/README.md Installs the necessary libraries for the unstructured parser on Ubuntu systems. ```bash apt-get install -y tesseract-ocr poppler-utils ``` -------------------------------- ### Example Migration Registration in registry.yaml Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_migrations/README.md Register a new migration by adding an entry to `migrations/registry.yaml`. Specify the migration name, order, and a description of its purpose. ```yaml manifest_migrations: - version: 6.45.2 migrations: - name: http_requester_url_base_to_url order: 1 description: | This migration updates the `url_base` field in the `HttpRequester` component spec to `url`. ``` -------------------------------- ### Running MockServer with Docker Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Starts a MockServer instance using Docker, mounting local expectations and configuring ports and logging. Use this to stub API responses during testing. ```bash 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 ``` -------------------------------- ### Install Poppler and Tesseract on macOS Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/sources/file_based/README.md Installs the necessary libraries for the unstructured parser on macOS using Homebrew. ```bash brew install poppler brew install tesseract ``` -------------------------------- ### Connector Builder Backend Configuration Structure Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/connector_builder/README.md Example JSON structure for the configuration file when running the Connector Builder backend. Includes special keys for injecting manifests and specifying commands. ```json { "config": , "__injected_declarative_manifest": {...}, "__command": <"resolve_manifest" | "test_read"> } ``` -------------------------------- ### Custom File-Based Spec Implementation Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/sources/file_based/README.md Example of extending AbstractFileBasedSpec to define connector specifications, including documentation URL and custom fields. ```python class CustomConfig(AbstractFileBasedSpec): @classmethod def documentation_url(cls) -> AnyUrl: return AnyUrl("https://docs.airbyte.com/integrations/sources/s3", scheme="https") a_spec_field: str = Field(title="A Spec Field", description="This is where you describe the fields of the spec", order=0) <...> ``` -------------------------------- ### Example Migration Skeleton in Python Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_migrations/README.md A skeleton class for creating a manifest migration. It inherits from `ManifestMigration` and implements `should_migrate`, `migrate`, and `validate` methods. ```python from airbyte_cdk.manifest_migrations.manifest_migration import TYPE_TAG, ManifestMigration, ManifestType class ExampleMigration(ManifestMigration): component_type = "ExampleComponent" original_key = "old_key" replacement_key = "new_key" def should_migrate(self, manifest: ManifestType) -> bool: return manifest[TYPE_TAG] == self.component_type and self.original_key in manifest def migrate(self, manifest: ManifestType) -> None: manifest[self.replacement_key] = manifest[self.original_key] manifest.pop(self.original_key, None) def validate(self, manifest: ManifestType) -> bool: return self.replacement_key in manifest and self.original_key not in manifest ``` -------------------------------- ### Custom File-Based Stream Reader Implementation Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/sources/file_based/README.md Example of extending AbstractStreamReader to implement custom logic for file operations and configuration handling specific to a storage system. ```python class CustomStreamReader(AbstractStreamReader): def open_file(self, remote_file: RemoteFile) -> FileHandler: <...> def get_matching_files( self, globs: List[str], logger: logging.Logger, ) -> Iterable[RemoteFile]: <...> @config.setter def config(self, value: Config): assert isinstance(value, CustomConfig) self._config = value ``` -------------------------------- ### Update Import Path for HttpStream Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md Starting from CDK 1.0.0, import classes like HttpStream directly from `airbyte_cdk` instead of lower-level `__init__` files. ```python from airbyte_cdk import HttpStream ``` -------------------------------- ### AsyncHttpJobRepository Sequence Diagram Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/sources/declarative/requesters/README.md Illustrates the sequence of operations for the `AsyncHttpJobRepository`, including job creation, polling, download, abort, and delete requests. Optional components are marked. ```mermaid sequenceDiagram participant AsyncHttpJobRepository as AsyncOrchestrator participant CreationRequester as creation_requester participant PollingRequester as polling_requester participant UrlRequester as download_target_requester (Optional) participant DownloadRetriever as download_retriever participant AbortRequester as abort_requester (Optional) participant DeleteRequester as delete_requester (Optional) participant Reporting Server as Async Reporting Server AsyncHttpJobRepository ->> CreationRequester: Initiate job creation CreationRequester ->> Reporting Server: Create job request Reporting Server -->> CreationRequester: Job ID response CreationRequester -->> AsyncHttpJobRepository: Job ID loop Poll for job status AsyncHttpJobRepository ->> PollingRequester: Check job status PollingRequester ->> Reporting Server: Status request (interpolation_context: `creation_response`) Reporting Server -->> PollingRequester: Status response PollingRequester -->> AsyncHttpJobRepository: Job status end alt Status: Ready AsyncHttpJobRepository ->> UrlRequester: Request download URLs (if applicable) UrlRequester ->> Reporting Server: URL request (interpolation_context: `polling_response`) Reporting Server -->> UrlRequester: Download URLs UrlRequester -->> AsyncHttpJobRepository: Download URLs AsyncHttpJobRepository ->> DownloadRetriever: Download reports DownloadRetriever ->> Reporting Server: Retrieve report data (interpolation_context: `download_target`, `creation_response`, `polling_response`) Reporting Server -->> DownloadRetriever: Report data DownloadRetriever -->> AsyncHttpJobRepository: Report data else Status: Failed AsyncHttpJobRepository ->> AbortRequester: Send abort request AbortRequester ->> Reporting Server: Abort job Reporting Server -->> AbortRequester: Abort confirmation AbortRequester -->> AsyncHttpJobRepository: Confirmation end AsyncHttpJobRepository ->> DeleteRequester: Send delete job request DeleteRequester ->> Reporting Server: Delete job Reporting Server -->> DeleteRequester: Deletion confirmation DeleteRequester -->> AsyncHttpJobRepository: Confirmation ``` -------------------------------- ### Build Manifest Server Docker Image Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Build the Docker image for the manifest server from the repository root. ```bash docker build -f airbyte_cdk/manifest_server/Dockerfile -t manifest-server . ``` -------------------------------- ### Run a connection check with source-declarative-manifest Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/cli/source_declarative_manifest/README.md Executes a connection check for a manifest-only connector. Requires a configuration file and the manifest path. ```bash source-declarative-manifest check --config secrets/config.json --manifest-path manifest.yaml ``` -------------------------------- ### View Ruff Options Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Display all available options and commands for the Ruff linter and formatter. ```bash poetry run ruff ``` -------------------------------- ### Build Connector with Local CDK using airbyte-ci Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Builds a connector image using a local version of the Airbyte CDK via the `airbyte-ci` CLI. This is useful for testing CDK features within a connector. ```bash # from the airbytehq/airbyte base directory airbyte-ci connectors --use-local-cdk --name= build ``` -------------------------------- ### Run Connector Builder Backend Locally Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/connector_builder/README.md Execute the Connector Builder backend locally using the main Python script. Requires specifying the configuration and catalog paths. ```bash python main.py read --config path/to/config --catalog path/to/catalog ``` -------------------------------- ### Run Connector Builder Docker Image Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/connector_builder/README.md Run the Connector Builder backend using a Docker container. Mounts a local secrets directory to provide configuration files. ```bash docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-declarative-manifest:dev read --config /secrets/config.json ``` -------------------------------- ### Enable Custom Components Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Enable custom Python components in manifest files by setting the AIRBYTE_ENABLE_UNSAFE_CODE environment variable. ```bash export AIRBYTE_ENABLE_UNSAFE_CODE=true ``` -------------------------------- ### Test Connector with Local CDK using airbyte-ci Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Runs a connector's full test suite, including CAT and unit tests, using a local version of the Airbyte CDK. Ensures compatibility and functionality of CDK changes. ```bash # from the airbytehq/airbyte base directory airbyte-ci connectors --use-local-cdk --name= test ``` -------------------------------- ### Read data with source-declarative-manifest Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/cli/source_declarative_manifest/README.md Reads data from a source using a provided configuration, catalog, and manifest. Optionally includes custom components. ```bash source-declarative-manifest read --config secrets/config.json --catalog integration_tests/configured_catalog.json --manifest-path manifest.yaml --components-path components.py ``` -------------------------------- ### List Available Poe Tasks Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Lists all available tasks that can be executed using Poe. ```bash poetry run poe list ``` -------------------------------- ### View All Poe Scripts Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Lists all available scripts that can be executed using Poe. ```bash poetry run poe ``` -------------------------------- ### Build Connector Builder Docker Image Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/connector_builder/README.md Build the Docker image for the Connector Builder backend. This command tags the image as 'airbyte/source-declarative-manifest:dev'. ```bash docker build -t airbyte/source-declarative-manifest:dev . ``` -------------------------------- ### Generate Declarative Schema File Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Run the 'build' command using Poetry and Poe to regenerate low-code CDK models from declarative component schemas and templates. This is necessary when changes are made to the models or the connector generator. ```bash poetry run poe build ``` -------------------------------- ### Run Manifest Server Docker Container Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Run the manifest server container, exposing port 8080. ```bash docker run -p 8080:8080 manifest-server ``` -------------------------------- ### Run Single Connector Acceptance Tests with Local CDK Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Executes Connector Acceptance Tests (CAT) for a specific connector using the local Airbyte CDK. This command is run from the connector's directory. ```bash airbyte-ci connectors --use-local-cdk --name= test ``` -------------------------------- ### /v1/manifest/check Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Validates connector configuration against a manifest. Returns success or failure status along with a message. ```APIDOC ## POST /v1/manifest/check ### Description Validates connector configuration against a manifest. Returns success or failure status along with a message. ### Method POST ### Endpoint /v1/manifest/check ### Parameters #### Request Body - **config** (object) - Required - The connector configuration to validate. - **manifest** (object) - Required - The manifest file content. ### Request Example { "config": { "api_key": "your_api_key" }, "manifest": { "type": "airbyte/source", "version": "1.0.0", "spec": { "connection_specification": { "type": "object", "properties": { "api_key": { "type": "string", "airbyte_secret": true } } } } } } ### Response #### Success Response (200) - **status** (string) - 'succeeded' or 'failed'. - **message** (string) - Details about the validation result. #### Response Example { "status": "succeeded", "message": "Configuration is valid." } ``` -------------------------------- ### VSCode launch.json Configuration for Debug Manifest Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/debug_manifest/README.md This JSON configuration is used in VSCode's launch.json file to set up the debugger for running manifest-only connectors. It specifies the Python interpreter, module to run, and arguments for commands like spec, check, discover, and read. ```json { "version": "0.2.0", "configurations": [ { "name": "Python: Debug Manifest", "type": "debugpy", "request": "launch", "console": "integratedTerminal", "cwd": "${workspaceFolder}/debug_manifest", "python": "/bin/python", // REPLACE ME "module": "debug_manifest", "args": [ // SPECIFY THE COMMAND: [spec, check, discover, read] "read", // SPECIFY THE MANIFEST FILE "--manifest-path", // PATH TO THE MANIFEST FILE "resources/manifest.yaml", // SPECIFY A COMPONENTS.PY FILE (OPTIONAL) "--components-path", // PATH TO THE COMPONENTS FILE "resources/components.py", // SPECIFY THE CONFIG "--config", // PATH TO THE CONFIG FILE "resources/config.json", // SPECIFY THE CATALOG "--catalog", // PATH TO THE CATALOG FILE "resources/catalog.json", // SPECIFY THE STATE (optional) // "--state", // PATH TO THE STATE FILE // "resources/state.json", // ADDITIONAL FLAGS, like `--debug` (optional) "--debug" ] } ] } ``` -------------------------------- ### Enable Datadog APM Tracing Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Enable Datadog APM tracing by setting the DD_ENABLED environment variable to true. This requires the 'ddtrace' dependency. ```bash export DD_ENABLED=true ``` -------------------------------- ### Serialize AirbyteMessage with Dataclasses Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md Demonstrates the recommended serialization of AirbyteMessage using dataclasses and serpyco-rs, contrasting it with the previous Pydantic v2 approach. ```python import orjson from airbyte_cdk.models import AirbyteMessage, AirbyteMessageSerializer # Before (pydantic model message serialization) AirbyteMessage().model_dump_json() # After (dataclass model serialization) orjson.dumps(AirbyteMessageSerializer.dump(AirbyteMessage())).decode() ``` -------------------------------- ### Run Manifest Server Tests Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Execute all manifest server tests using Poetry and pytest. ```bash poetry run pytest unit_tests/manifest_server/ -v ``` -------------------------------- ### Configure JWT Authentication Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Enable JWT bearer token authentication by setting the AB_JWT_SIGNATURE_SECRET environment variable. ```bash export AB_JWT_SIGNATURE_SECRET="your-jwt-secret-key" ``` -------------------------------- ### /v1/manifest/discover Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Discovers available streams from a manifest and returns the catalog of streams. ```APIDOC ## POST /v1/manifest/discover ### Description Discovers available streams from a manifest and returns the catalog of streams. ### Method POST ### Endpoint /v1/manifest/discover ### Parameters #### Request Body - **manifest** (object) - Required - The manifest file content. ### Request Example { "manifest": { "type": "airbyte/source", "version": "1.0.0", "spec": { "connection_specification": { "type": "object", "properties": { "api_key": { "type": "string", "airbyte_secret": true } } } } } } ### Response #### Success Response (200) - **catalog** (object) - The catalog of available streams. #### Response Example { "catalog": { "streams": [ { "name": "users", "json_schema": { "type": "object", "properties": { "user_id": {"type": "string"}, "name": {"type": "string"} } }, "supported_sync_modes": ["full_resync", "incremental"] } ] } } ``` -------------------------------- ### Local CDK Development in pyproject.toml Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Configures a Python connector's `pyproject.toml` to use a local version of the Airbyte CDK for development. This allows testing changes made directly to the CDK. ```toml airbyte_cdk = { path = "../../../../airbyte-python-cdk", develop = true } ``` -------------------------------- ### Generate OpenAPI Specification Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Generate the OpenAPI specification in YAML format, either to the default location or a custom path. ```bash manifest-server generate-openapi ``` ```bash manifest-server generate-openapi --output /path/to/openapi.yaml ``` -------------------------------- ### Run Local Code Checks Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Perform linting, type-checking on modified code, and run unit tests with coverage in a single command. ```bash poetry run poe check-local ``` -------------------------------- ### /v1/manifest/full_resolve Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Fully resolves a manifest, including dynamic stream generation up to specified limits. ```APIDOC ## POST /v1/manifest/full_resolve ### Description Fully resolves a manifest, including dynamic stream generation up to specified limits. ### Method POST ### Endpoint /v1/manifest/full_resolve ### Parameters #### Request Body - **manifest** (object) - Required - The manifest file content. - **max_slices** (integer) - Optional - Maximum number of slices to generate for dynamic streams. - **max_records_per_slice** (integer) - Optional - Maximum number of records per slice for dynamic streams. ### Request Example { "manifest": { "type": "airbyte/source", "version": "1.0.0", "spec": { "connection_specification": { "type": "object", "properties": { "api_key": { "type": "string", "airbyte_secret": true } } } } }, "max_slices": 10, "max_records_per_slice": 1000 } ### Response #### Success Response (200) - **resolved_manifest** (object) - The fully resolved manifest with dynamic streams. #### Response Example { "resolved_manifest": { "type": "airbyte/source", "version": "1.0.0", "spec": { "connection_specification": { "type": "object", "properties": { "api_key": { "type": "string", "airbyte_secret": true } } } }, "streams": [ { "name": "users", "json_schema": { "type": "object", "properties": { "user_id": {"type": "string"}, "name": {"type": "string"} } }, "supported_sync_modes": ["full_resync", "incremental"] }, { "name": "dynamic_stream_1", "json_schema": { "type": "object", "properties": { "dynamic_field": {"type": "string"} } }, "supported_sync_modes": ["full_resync"] } ] } } ``` -------------------------------- ### Run Unit Tests Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Executes all unit tests for the project using pytest. ```bash poetry run pytest ``` -------------------------------- ### Update Imports for Logging Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md When migrating from `AirbyteLogger`, remove the import of `AirbyteLogger` from `airbyte_cdk` and add `import logging`. ```python from airbyte_cdk import AirbyteLogger ``` ```python import logging ``` -------------------------------- ### Make Authenticated Request Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Include a valid JWT token in the Authorization header for authenticated requests. ```bash curl -H "Authorization: Bearer " \ http://localhost:8000/v1/manifest/test_read ``` -------------------------------- ### Run Fast Pytest Tests Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Execute only the Pytest tests that are not flagged as 'slow'. This should complete in under 5 minutes. ```bash poetry run pytest-fast ``` -------------------------------- ### /v1/manifest/resolve Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Resolves a manifest to its final configuration without dynamic stream generation. ```APIDOC ## POST /v1/manifest/resolve ### Description Resolves a manifest to its final configuration without dynamic stream generation. ### Method POST ### Endpoint /v1/manifest/resolve ### Parameters #### Request Body - **manifest** (object) - Required - The manifest file content. ### Request Example { "manifest": { "type": "airbyte/source", "version": "1.0.0", "spec": { "connection_specification": { "type": "object", "properties": { "api_key": { "type": "string", "airbyte_secret": true } } } } } } ### Response #### Success Response (200) - **resolved_manifest** (object) - The fully resolved manifest. #### Response Example { "resolved_manifest": { "type": "airbyte/source", "version": "1.0.0", "spec": { "connection_specification": { "type": "object", "properties": { "api_key": { "type": "string", "airbyte_secret": true } } } }, "streams": [ { "name": "users", "json_schema": { "type": "object", "properties": { "user_id": {"type": "string"}, "name": {"type": "string"} } }, "supported_sync_modes": ["full_resync", "incremental"] } ] } } ``` -------------------------------- ### MockServer Expectation File Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Defines HTTP request and response for MockServer to emulate API behavior. Used when direct API access is unavailable for testing. ```json { "httpRequest": { "method": "GET", "path": "/data" }, "httpResponse": { "body": "{\"data\": [{\"record_key\": 1}, {\"record_key\": 2}]}" } } ``` -------------------------------- ### Run Pytest Tests Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Execute Pytest tests locally. You can pass additional pytest options by running directly with `python -m pytest`. ```bash poetry run poe pytest ``` ```bash python -m pytest -s unit_tests ``` -------------------------------- ### Import Pydantic V1 models with Pydantic V2 Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md When upgrading to Pydantic V2, use `pydantic.v1` for continued compatibility with Pydantic V1 models. Ensure correct imports for specific components like `ValidationError`. ```python from pydantic.v1 import BaseModel from pydantic.v1.error_wrappers import ValidationError from pydantic.v1.main import ModelMetaclass from pydantic.v1.typing import resolve_annotations ``` -------------------------------- ### Run Lint Checks Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Performs lint checks on the codebase using Poe tasks. ```bash poetry run poe lint ``` -------------------------------- ### Format Python Code with Ruff Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Autoformat only Python code files, excluding other file types like markdown or yaml. ```bash poetry run ruff format ``` -------------------------------- ### Update Assertions for Protocol Models Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md When testing methods that return protocol models like `AirbyteStateBlob`, update assertions to either compare directly with the model or use `.dict()` or `.str()` for comparison, depending on whether the serialized output or the model itself is the focus. ```python # Before assert stream_read.slices[1].state[0].stream.stream_state == {"a_timestamp": 123} # After - Option 1 from airbyte_cdk.models import AirbyteStateBlob assert stream_read.slices[1].state[0].stream.stream_state == AirbyteStateBlob(a_timestamp=123) # After - Option 2 assert stream_read.slices[1].state[0].stream.stream_state.dict() == {"a_timestamp": 123} ``` -------------------------------- ### Add ConcurrencyLevel Component to Manifest Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md Includes the `ConcurrencyLevel` component in the `manifest.yaml` file to enable concurrent processing for low-code connectors in CDK version 6.0.0. ```yaml concurrency_level: type: ConcurrencyLevel default_concurrency: "{{ config['num_workers'] or 10 }}" max_concurrency: 20 ``` -------------------------------- ### Ignoring Deptry Dependency Errors Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Configure pyproject.toml to ignore specific Deptry errors, such as unused dependencies (DEP002), when Deptry cannot detect package usage correctly. Include an inline comment explaining the reason for the ignore. ```toml [tool.deptry.per_rule_ignores] # DEP002: Project should not contain unused dependencies. DEP002 = [ "google-cloud-secret-manager", # Deptry can't detect that `google.cloud.secretmanager_v1` uses this package ] ``` -------------------------------- ### Autoformat Code Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/CONTRIBUTING.md Applies autoformatting fixes to the codebase using Poe tasks. ```bash poetry run poe format-fix ``` -------------------------------- ### /v1/manifest/test_read Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/airbyte_cdk/manifest_server/README.md Tests reading from a specific stream defined in the manifest. Supports configurable limits for records, pages, and slices. ```APIDOC ## POST /v1/manifest/test_read ### Description Tests reading from a specific stream defined in the manifest. Supports configurable limits for records, pages, and slices. ### Method POST ### Endpoint /v1/manifest/test_read ### Parameters #### Request Body - **records** (integer) - Optional - Maximum number of records to read. - **pages** (integer) - Optional - Maximum number of pages to read. - **slices** (integer) - Optional - Maximum number of slices to read. ### Request Example { "records": 100, "pages": 5, "slices": 2 } ### Response #### Success Response (200) - **data** (array) - List of records read from the stream. - **next_page_token** (string) - Token for fetching the next page of results. #### Response Example { "data": [ {"field1": "value1", "field2": "value2"} ], "next_page_token": "some_token" } ``` -------------------------------- ### Update Source Class Signature for Concurrent Processing Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md Modifies the `__init__` method signature in `source.py` to accept catalog, config, and state parameters for concurrent processing in CDK version 6.0.0. ```python class SourceName(YamlDeclarativeSource): def __init__(self, catalog: Optional[ConfiguredAirbyteCatalog], config: Optional[Mapping[str, Any]], state: TState, **kwargs): super().__init__(catalog=catalog, config=config, state=state, **{"path_to_yaml": "manifest.yaml"}) ``` -------------------------------- ### Migrate Type Annotation from AirbyteLogger to logging.Logger Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md Update type annotations for logger parameters from `AirbyteLogger` to `logging.Logger` to reflect the deprecation of `AirbyteLogger`. ```python def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]: ``` ```python def check_connection(self, logger: logging.Logger, config: Mapping[str, Any]) -> Tuple[bool, any]: ``` -------------------------------- ### Update Run Script for Concurrent Processing Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md Updates the `run.py` script to pass necessary variables when initializing the source for concurrent processing in CDK version 6.0.0. ```python def _get_source(args: List[str]): catalog_path = AirbyteEntrypoint.extract_catalog(args) config_path = AirbyteEntrypoint.extract_config(args) state_path = AirbyteEntrypoint.extract_state(args) try: return SourceName( SourceName.read_catalog(catalog_path) if catalog_path else None, SourceName.read_config(config_path) if config_path else None, SourceName.read_state(state_path) if state_path else None, ) except Exception as error: print( orjson.dumps( AirbyteMessageSerializer.dump( AirbyteMessage( type=Type.TRACE, trace=AirbyteTraceMessage( type=TraceType.ERROR, emitted_at=int(datetime.now().timestamp() * 1000), error=AirbyteErrorTraceMessage( message=f"Error starting the sync. This could be due to an invalid configuration or catalog. Please contact Support for assistance. Error: {error}", stack_trace=traceback.format_exc(), ), ), ) ) ).decode() ) return None def run(): _args = sys.argv[1:] source = _get_source(_args) if source: launch(source, _args) ``` -------------------------------- ### Update Jinja Interpolation Context for stream_state Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md Replaces `stream_state` with `stream_interval` in Jinja interpolation contexts for low-code connectors to adapt to CDK version 6.34.0. ```yaml # Before record_filter: type: RecordFilter condition: "{{ stream_state['updated_at'] }}" # After record_filter: type: RecordFilter condition: "{{ stream_interval['start_date'] }}" ``` -------------------------------- ### Serialize Pandas DataFrame with Datetime Objects Source: https://github.com/airbytehq/airbyte-python-cdk/blob/main/cdk-migrations.md Shows how to serialize a Pandas DataFrame, ensuring that date-time objects are converted to native JSON types compatible with orjson, addressing potential serialization issues. ```python # Before yield from df.to_dict(orient="records") # After - Option 1 yield orjson.loads(df.to_json(orient="records", date_format="iso", date_unit="us")) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.