airbyte-cdk 0.72.1__py3-none-any.whl → 6.17.1.dev1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- airbyte_cdk/__init__.py +355 -6
- airbyte_cdk/cli/__init__.py +1 -0
- airbyte_cdk/cli/source_declarative_manifest/__init__.py +5 -0
- airbyte_cdk/cli/source_declarative_manifest/_run.py +230 -0
- airbyte_cdk/cli/source_declarative_manifest/spec.json +17 -0
- airbyte_cdk/config_observation.py +29 -10
- airbyte_cdk/connector.py +24 -24
- airbyte_cdk/connector_builder/README.md +53 -0
- airbyte_cdk/connector_builder/connector_builder_handler.py +37 -11
- airbyte_cdk/connector_builder/main.py +45 -13
- airbyte_cdk/connector_builder/message_grouper.py +189 -50
- airbyte_cdk/connector_builder/models.py +3 -2
- airbyte_cdk/destinations/__init__.py +4 -3
- airbyte_cdk/destinations/destination.py +54 -20
- airbyte_cdk/destinations/vector_db_based/README.md +37 -0
- airbyte_cdk/destinations/vector_db_based/config.py +40 -17
- airbyte_cdk/destinations/vector_db_based/document_processor.py +56 -17
- airbyte_cdk/destinations/vector_db_based/embedder.py +57 -15
- airbyte_cdk/destinations/vector_db_based/test_utils.py +14 -4
- airbyte_cdk/destinations/vector_db_based/utils.py +8 -2
- airbyte_cdk/destinations/vector_db_based/writer.py +24 -5
- airbyte_cdk/entrypoint.py +153 -44
- airbyte_cdk/exception_handler.py +21 -3
- airbyte_cdk/logger.py +30 -44
- airbyte_cdk/models/__init__.py +13 -2
- airbyte_cdk/models/airbyte_protocol.py +86 -1
- airbyte_cdk/models/airbyte_protocol_serializers.py +44 -0
- airbyte_cdk/models/file_transfer_record_message.py +13 -0
- airbyte_cdk/models/well_known_types.py +1 -1
- airbyte_cdk/sources/__init__.py +5 -1
- airbyte_cdk/sources/abstract_source.py +125 -79
- airbyte_cdk/sources/concurrent_source/__init__.py +7 -2
- airbyte_cdk/sources/concurrent_source/concurrent_read_processor.py +102 -36
- airbyte_cdk/sources/concurrent_source/concurrent_source.py +29 -36
- airbyte_cdk/sources/concurrent_source/concurrent_source_adapter.py +94 -10
- airbyte_cdk/sources/concurrent_source/stream_thread_exception.py +25 -0
- airbyte_cdk/sources/concurrent_source/thread_pool_manager.py +20 -14
- airbyte_cdk/sources/config.py +3 -2
- airbyte_cdk/sources/connector_state_manager.py +49 -83
- airbyte_cdk/sources/declarative/async_job/job.py +52 -0
- airbyte_cdk/sources/declarative/async_job/job_orchestrator.py +497 -0
- airbyte_cdk/sources/declarative/async_job/job_tracker.py +75 -0
- airbyte_cdk/sources/declarative/async_job/repository.py +35 -0
- airbyte_cdk/sources/declarative/async_job/status.py +24 -0
- airbyte_cdk/sources/declarative/async_job/timer.py +39 -0
- airbyte_cdk/sources/declarative/auth/__init__.py +2 -3
- airbyte_cdk/sources/declarative/auth/declarative_authenticator.py +3 -1
- airbyte_cdk/sources/declarative/auth/jwt.py +191 -0
- airbyte_cdk/sources/declarative/auth/oauth.py +60 -20
- airbyte_cdk/sources/declarative/auth/selective_authenticator.py +10 -2
- airbyte_cdk/sources/declarative/auth/token.py +28 -10
- airbyte_cdk/sources/declarative/auth/token_provider.py +9 -8
- airbyte_cdk/sources/declarative/checks/check_stream.py +16 -8
- airbyte_cdk/sources/declarative/checks/connection_checker.py +4 -2
- airbyte_cdk/sources/declarative/concurrency_level/__init__.py +7 -0
- airbyte_cdk/sources/declarative/concurrency_level/concurrency_level.py +50 -0
- airbyte_cdk/sources/declarative/concurrent_declarative_source.py +490 -0
- airbyte_cdk/sources/declarative/datetime/datetime_parser.py +4 -0
- airbyte_cdk/sources/declarative/datetime/min_max_datetime.py +26 -6
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml +1185 -85
- airbyte_cdk/sources/declarative/declarative_source.py +5 -2
- airbyte_cdk/sources/declarative/declarative_stream.py +95 -9
- airbyte_cdk/sources/declarative/decoders/__init__.py +23 -2
- airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py +97 -0
- airbyte_cdk/sources/declarative/decoders/decoder.py +11 -4
- airbyte_cdk/sources/declarative/decoders/json_decoder.py +92 -5
- airbyte_cdk/sources/declarative/decoders/noop_decoder.py +21 -0
- airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py +39 -0
- airbyte_cdk/sources/declarative/decoders/xml_decoder.py +98 -0
- airbyte_cdk/sources/declarative/extractors/__init__.py +12 -1
- airbyte_cdk/sources/declarative/extractors/dpath_extractor.py +29 -24
- airbyte_cdk/sources/declarative/extractors/http_selector.py +4 -5
- airbyte_cdk/sources/declarative/extractors/record_extractor.py +2 -3
- airbyte_cdk/sources/declarative/extractors/record_filter.py +63 -8
- airbyte_cdk/sources/declarative/extractors/record_selector.py +85 -26
- airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py +177 -0
- airbyte_cdk/sources/declarative/extractors/type_transformer.py +55 -0
- airbyte_cdk/sources/declarative/incremental/__init__.py +31 -3
- airbyte_cdk/sources/declarative/incremental/concurrent_partition_cursor.py +340 -0
- airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py +156 -48
- airbyte_cdk/sources/declarative/incremental/declarative_cursor.py +13 -0
- airbyte_cdk/sources/declarative/incremental/global_substream_cursor.py +350 -0
- airbyte_cdk/sources/declarative/incremental/per_partition_cursor.py +174 -74
- airbyte_cdk/sources/declarative/incremental/per_partition_with_global.py +200 -0
- airbyte_cdk/sources/declarative/incremental/resumable_full_refresh_cursor.py +122 -0
- airbyte_cdk/sources/declarative/interpolation/filters.py +27 -1
- airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py +23 -5
- airbyte_cdk/sources/declarative/interpolation/interpolated_mapping.py +12 -8
- airbyte_cdk/sources/declarative/interpolation/interpolated_nested_mapping.py +13 -6
- airbyte_cdk/sources/declarative/interpolation/interpolated_string.py +21 -6
- airbyte_cdk/sources/declarative/interpolation/interpolation.py +9 -3
- airbyte_cdk/sources/declarative/interpolation/jinja.py +72 -37
- airbyte_cdk/sources/declarative/interpolation/macros.py +72 -17
- airbyte_cdk/sources/declarative/manifest_declarative_source.py +193 -52
- airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py +98 -0
- airbyte_cdk/sources/declarative/migrations/state_migration.py +24 -0
- airbyte_cdk/sources/declarative/models/__init__.py +1 -1
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py +1319 -603
- airbyte_cdk/sources/declarative/parsers/custom_exceptions.py +2 -2
- airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py +26 -4
- airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py +26 -15
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +1759 -225
- airbyte_cdk/sources/declarative/partition_routers/__init__.py +24 -4
- airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py +65 -0
- airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py +176 -0
- airbyte_cdk/sources/declarative/partition_routers/list_partition_router.py +39 -9
- airbyte_cdk/sources/declarative/partition_routers/partition_router.py +62 -0
- airbyte_cdk/sources/declarative/partition_routers/single_partition_router.py +15 -3
- airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py +222 -39
- airbyte_cdk/sources/declarative/requesters/error_handlers/__init__.py +19 -5
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/__init__.py +3 -1
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py +19 -7
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py +19 -7
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/header_helper.py +4 -2
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py +41 -9
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py +29 -14
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategy.py +5 -13
- airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py +32 -16
- airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py +46 -56
- airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py +40 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/error_handler.py +6 -32
- airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py +119 -41
- airbyte_cdk/sources/declarative/requesters/http_job_repository.py +228 -0
- airbyte_cdk/sources/declarative/requesters/http_requester.py +98 -344
- airbyte_cdk/sources/declarative/requesters/paginators/__init__.py +14 -3
- airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py +105 -46
- airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py +14 -8
- airbyte_cdk/sources/declarative/requesters/paginators/paginator.py +19 -8
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/__init__.py +9 -3
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py +53 -21
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py +42 -19
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py +25 -12
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py +13 -10
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py +26 -13
- airbyte_cdk/sources/declarative/requesters/request_options/__init__.py +15 -2
- airbyte_cdk/sources/declarative/requesters/request_options/datetime_based_request_options_provider.py +91 -0
- airbyte_cdk/sources/declarative/requesters/request_options/default_request_options_provider.py +60 -0
- airbyte_cdk/sources/declarative/requesters/request_options/interpolated_nested_request_input_provider.py +31 -14
- airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_input_provider.py +27 -15
- airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py +63 -10
- airbyte_cdk/sources/declarative/requesters/request_options/request_options_provider.py +1 -1
- airbyte_cdk/sources/declarative/requesters/requester.py +9 -17
- airbyte_cdk/sources/declarative/resolvers/__init__.py +41 -0
- airbyte_cdk/sources/declarative/resolvers/components_resolver.py +55 -0
- airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py +136 -0
- airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py +112 -0
- airbyte_cdk/sources/declarative/retrievers/__init__.py +6 -2
- airbyte_cdk/sources/declarative/retrievers/async_retriever.py +100 -0
- airbyte_cdk/sources/declarative/retrievers/retriever.py +1 -3
- airbyte_cdk/sources/declarative/retrievers/simple_retriever.py +229 -73
- airbyte_cdk/sources/declarative/schema/__init__.py +14 -1
- airbyte_cdk/sources/declarative/schema/default_schema_loader.py +5 -3
- airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py +236 -0
- airbyte_cdk/sources/declarative/schema/json_file_schema_loader.py +8 -8
- airbyte_cdk/sources/declarative/spec/spec.py +12 -5
- airbyte_cdk/sources/declarative/stream_slicers/__init__.py +1 -2
- airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py +88 -0
- airbyte_cdk/sources/declarative/stream_slicers/stream_slicer.py +9 -14
- airbyte_cdk/sources/declarative/transformations/add_fields.py +19 -11
- airbyte_cdk/sources/declarative/transformations/flatten_fields.py +52 -0
- airbyte_cdk/sources/declarative/transformations/keys_replace_transformation.py +61 -0
- airbyte_cdk/sources/declarative/transformations/keys_to_lower_transformation.py +22 -0
- airbyte_cdk/sources/declarative/transformations/keys_to_snake_transformation.py +68 -0
- airbyte_cdk/sources/declarative/transformations/remove_fields.py +13 -10
- airbyte_cdk/sources/declarative/transformations/transformation.py +5 -5
- airbyte_cdk/sources/declarative/types.py +19 -110
- airbyte_cdk/sources/declarative/yaml_declarative_source.py +31 -10
- airbyte_cdk/sources/embedded/base_integration.py +16 -5
- airbyte_cdk/sources/embedded/catalog.py +16 -4
- airbyte_cdk/sources/embedded/runner.py +19 -3
- airbyte_cdk/sources/embedded/tools.py +5 -2
- airbyte_cdk/sources/file_based/README.md +152 -0
- airbyte_cdk/sources/file_based/__init__.py +24 -0
- airbyte_cdk/sources/file_based/availability_strategy/__init__.py +9 -2
- airbyte_cdk/sources/file_based/availability_strategy/abstract_file_based_availability_strategy.py +22 -6
- airbyte_cdk/sources/file_based/availability_strategy/default_file_based_availability_strategy.py +46 -10
- airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py +47 -10
- airbyte_cdk/sources/file_based/config/avro_format.py +2 -1
- airbyte_cdk/sources/file_based/config/csv_format.py +29 -10
- airbyte_cdk/sources/file_based/config/excel_format.py +18 -0
- airbyte_cdk/sources/file_based/config/file_based_stream_config.py +16 -4
- airbyte_cdk/sources/file_based/config/jsonl_format.py +2 -1
- airbyte_cdk/sources/file_based/config/parquet_format.py +2 -1
- airbyte_cdk/sources/file_based/config/unstructured_format.py +13 -5
- airbyte_cdk/sources/file_based/discovery_policy/__init__.py +6 -2
- airbyte_cdk/sources/file_based/discovery_policy/abstract_discovery_policy.py +2 -4
- airbyte_cdk/sources/file_based/discovery_policy/default_discovery_policy.py +7 -2
- airbyte_cdk/sources/file_based/exceptions.py +18 -15
- airbyte_cdk/sources/file_based/file_based_source.py +140 -33
- airbyte_cdk/sources/file_based/file_based_stream_reader.py +69 -5
- airbyte_cdk/sources/file_based/file_types/__init__.py +14 -1
- airbyte_cdk/sources/file_based/file_types/avro_parser.py +75 -24
- airbyte_cdk/sources/file_based/file_types/csv_parser.py +116 -34
- airbyte_cdk/sources/file_based/file_types/excel_parser.py +196 -0
- airbyte_cdk/sources/file_based/file_types/file_transfer.py +37 -0
- airbyte_cdk/sources/file_based/file_types/file_type_parser.py +4 -1
- airbyte_cdk/sources/file_based/file_types/jsonl_parser.py +24 -8
- airbyte_cdk/sources/file_based/file_types/parquet_parser.py +60 -18
- airbyte_cdk/sources/file_based/file_types/unstructured_parser.py +141 -41
- airbyte_cdk/sources/file_based/remote_file.py +1 -1
- airbyte_cdk/sources/file_based/schema_helpers.py +38 -10
- airbyte_cdk/sources/file_based/schema_validation_policies/__init__.py +3 -1
- airbyte_cdk/sources/file_based/schema_validation_policies/abstract_schema_validation_policy.py +3 -1
- airbyte_cdk/sources/file_based/schema_validation_policies/default_schema_validation_policies.py +16 -5
- airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py +50 -13
- airbyte_cdk/sources/file_based/stream/concurrent/adapters.py +67 -27
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/__init__.py +5 -1
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/abstract_concurrent_file_based_cursor.py +14 -23
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_concurrent_cursor.py +54 -18
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_final_state_cursor.py +21 -9
- airbyte_cdk/sources/file_based/stream/cursor/abstract_file_based_cursor.py +3 -1
- airbyte_cdk/sources/file_based/stream/cursor/default_file_based_cursor.py +27 -10
- airbyte_cdk/sources/file_based/stream/default_file_based_stream.py +147 -45
- airbyte_cdk/sources/http_logger.py +8 -3
- airbyte_cdk/sources/message/__init__.py +7 -1
- airbyte_cdk/sources/message/repository.py +18 -4
- airbyte_cdk/sources/source.py +42 -38
- airbyte_cdk/sources/streams/__init__.py +2 -2
- airbyte_cdk/sources/streams/availability_strategy.py +54 -3
- airbyte_cdk/sources/streams/call_rate.py +64 -21
- airbyte_cdk/sources/streams/checkpoint/__init__.py +26 -0
- airbyte_cdk/sources/streams/checkpoint/checkpoint_reader.py +335 -0
- airbyte_cdk/sources/{declarative/incremental → streams/checkpoint}/cursor.py +17 -14
- airbyte_cdk/sources/streams/checkpoint/per_partition_key_serializer.py +22 -0
- airbyte_cdk/sources/streams/checkpoint/resumable_full_refresh_cursor.py +51 -0
- airbyte_cdk/sources/streams/checkpoint/substream_resumable_full_refresh_cursor.py +110 -0
- airbyte_cdk/sources/streams/concurrent/README.md +7 -0
- airbyte_cdk/sources/streams/concurrent/abstract_stream.py +7 -2
- airbyte_cdk/sources/streams/concurrent/adapters.py +84 -75
- airbyte_cdk/sources/streams/concurrent/availability_strategy.py +30 -2
- airbyte_cdk/sources/streams/concurrent/cursor.py +313 -48
- airbyte_cdk/sources/streams/concurrent/default_stream.py +12 -3
- airbyte_cdk/sources/streams/concurrent/exceptions.py +3 -0
- airbyte_cdk/sources/streams/concurrent/helpers.py +14 -3
- airbyte_cdk/sources/streams/concurrent/partition_enqueuer.py +12 -3
- airbyte_cdk/sources/streams/concurrent/partition_reader.py +10 -3
- airbyte_cdk/sources/streams/concurrent/partitions/partition.py +1 -16
- airbyte_cdk/sources/streams/concurrent/partitions/stream_slicer.py +21 -0
- airbyte_cdk/sources/streams/concurrent/partitions/types.py +15 -5
- airbyte_cdk/sources/streams/concurrent/state_converters/abstract_stream_state_converter.py +109 -17
- airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py +90 -72
- airbyte_cdk/sources/streams/core.py +412 -87
- airbyte_cdk/sources/streams/http/__init__.py +2 -1
- airbyte_cdk/sources/streams/http/availability_strategy.py +12 -101
- airbyte_cdk/sources/streams/http/error_handlers/__init__.py +22 -0
- airbyte_cdk/sources/streams/http/error_handlers/backoff_strategy.py +28 -0
- airbyte_cdk/sources/streams/http/error_handlers/default_backoff_strategy.py +17 -0
- airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py +86 -0
- airbyte_cdk/sources/streams/http/error_handlers/error_handler.py +42 -0
- airbyte_cdk/sources/streams/http/error_handlers/error_message_parser.py +19 -0
- airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py +110 -0
- airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py +52 -0
- airbyte_cdk/sources/streams/http/error_handlers/response_models.py +65 -0
- airbyte_cdk/sources/streams/http/exceptions.py +27 -7
- airbyte_cdk/sources/streams/http/http.py +369 -246
- airbyte_cdk/sources/streams/http/http_client.py +531 -0
- airbyte_cdk/sources/streams/http/rate_limiting.py +76 -12
- airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +28 -9
- airbyte_cdk/sources/streams/http/requests_native_auth/abstract_token.py +2 -1
- airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py +90 -35
- airbyte_cdk/sources/streams/http/requests_native_auth/token.py +13 -3
- airbyte_cdk/sources/types.py +154 -0
- airbyte_cdk/sources/utils/record_helper.py +36 -21
- airbyte_cdk/sources/utils/schema_helpers.py +13 -6
- airbyte_cdk/sources/utils/slice_logger.py +4 -1
- airbyte_cdk/sources/utils/transform.py +54 -20
- airbyte_cdk/sql/_util/hashing.py +34 -0
- airbyte_cdk/sql/_util/name_normalizers.py +92 -0
- airbyte_cdk/sql/constants.py +32 -0
- airbyte_cdk/sql/exceptions.py +235 -0
- airbyte_cdk/sql/secrets.py +123 -0
- airbyte_cdk/sql/shared/__init__.py +15 -0
- airbyte_cdk/sql/shared/catalog_providers.py +145 -0
- airbyte_cdk/sql/shared/sql_processor.py +786 -0
- airbyte_cdk/sql/types.py +160 -0
- airbyte_cdk/test/catalog_builder.py +70 -18
- airbyte_cdk/test/entrypoint_wrapper.py +117 -42
- airbyte_cdk/test/mock_http/__init__.py +1 -1
- airbyte_cdk/test/mock_http/matcher.py +6 -0
- airbyte_cdk/test/mock_http/mocker.py +57 -10
- airbyte_cdk/test/mock_http/request.py +19 -3
- airbyte_cdk/test/mock_http/response.py +3 -1
- airbyte_cdk/test/mock_http/response_builder.py +32 -16
- airbyte_cdk/test/state_builder.py +18 -10
- airbyte_cdk/test/utils/__init__.py +1 -0
- airbyte_cdk/test/utils/data.py +24 -0
- airbyte_cdk/test/utils/http_mocking.py +16 -0
- airbyte_cdk/test/utils/manifest_only_fixtures.py +60 -0
- airbyte_cdk/test/utils/reading.py +26 -0
- airbyte_cdk/utils/__init__.py +2 -1
- airbyte_cdk/utils/airbyte_secrets_utils.py +5 -3
- airbyte_cdk/utils/analytics_message.py +10 -2
- airbyte_cdk/utils/datetime_format_inferrer.py +4 -1
- airbyte_cdk/utils/event_timing.py +10 -10
- airbyte_cdk/utils/mapping_helpers.py +3 -1
- airbyte_cdk/utils/message_utils.py +20 -11
- airbyte_cdk/utils/print_buffer.py +75 -0
- airbyte_cdk/utils/schema_inferrer.py +198 -28
- airbyte_cdk/utils/slice_hasher.py +30 -0
- airbyte_cdk/utils/spec_schema_transformations.py +6 -3
- airbyte_cdk/utils/stream_status_utils.py +8 -1
- airbyte_cdk/utils/traced_exception.py +61 -21
- airbyte_cdk-6.17.1.dev1.dist-info/METADATA +109 -0
- airbyte_cdk-6.17.1.dev1.dist-info/RECORD +350 -0
- {airbyte_cdk-0.72.1.dist-info → airbyte_cdk-6.17.1.dev1.dist-info}/WHEEL +1 -2
- airbyte_cdk-6.17.1.dev1.dist-info/entry_points.txt +3 -0
- airbyte_cdk/sources/declarative/create_partial.py +0 -92
- airbyte_cdk/sources/declarative/parsers/class_types_registry.py +0 -102
- airbyte_cdk/sources/declarative/parsers/default_implementation_registry.py +0 -64
- airbyte_cdk/sources/declarative/requesters/error_handlers/response_action.py +0 -16
- airbyte_cdk/sources/declarative/requesters/error_handlers/response_status.py +0 -68
- airbyte_cdk/sources/declarative/stream_slicers/cartesian_product_stream_slicer.py +0 -114
- airbyte_cdk/sources/deprecated/base_source.py +0 -94
- airbyte_cdk/sources/deprecated/client.py +0 -99
- airbyte_cdk/sources/singer/__init__.py +0 -8
- airbyte_cdk/sources/singer/singer_helpers.py +0 -304
- airbyte_cdk/sources/singer/source.py +0 -186
- airbyte_cdk/sources/streams/concurrent/partitions/record.py +0 -23
- airbyte_cdk/sources/streams/http/auth/__init__.py +0 -17
- airbyte_cdk/sources/streams/http/auth/core.py +0 -29
- airbyte_cdk/sources/streams/http/auth/oauth.py +0 -113
- airbyte_cdk/sources/streams/http/auth/token.py +0 -47
- airbyte_cdk/sources/streams/utils/stream_helper.py +0 -40
- airbyte_cdk/sources/utils/catalog_helpers.py +0 -22
- airbyte_cdk/sources/utils/schema_models.py +0 -84
- airbyte_cdk-0.72.1.dist-info/METADATA +0 -243
- airbyte_cdk-0.72.1.dist-info/RECORD +0 -466
- airbyte_cdk-0.72.1.dist-info/top_level.txt +0 -3
- source_declarative_manifest/main.py +0 -29
- unit_tests/connector_builder/__init__.py +0 -3
- unit_tests/connector_builder/test_connector_builder_handler.py +0 -871
- unit_tests/connector_builder/test_message_grouper.py +0 -713
- unit_tests/connector_builder/utils.py +0 -27
- unit_tests/destinations/test_destination.py +0 -243
- unit_tests/singer/test_singer_helpers.py +0 -56
- unit_tests/singer/test_singer_source.py +0 -112
- unit_tests/sources/__init__.py +0 -0
- unit_tests/sources/concurrent_source/__init__.py +0 -3
- unit_tests/sources/concurrent_source/test_concurrent_source_adapter.py +0 -106
- unit_tests/sources/declarative/__init__.py +0 -3
- unit_tests/sources/declarative/auth/__init__.py +0 -3
- unit_tests/sources/declarative/auth/test_oauth.py +0 -331
- unit_tests/sources/declarative/auth/test_selective_authenticator.py +0 -39
- unit_tests/sources/declarative/auth/test_session_token_auth.py +0 -182
- unit_tests/sources/declarative/auth/test_token_auth.py +0 -200
- unit_tests/sources/declarative/auth/test_token_provider.py +0 -73
- unit_tests/sources/declarative/checks/__init__.py +0 -3
- unit_tests/sources/declarative/checks/test_check_stream.py +0 -146
- unit_tests/sources/declarative/decoders/__init__.py +0 -0
- unit_tests/sources/declarative/decoders/test_json_decoder.py +0 -16
- unit_tests/sources/declarative/external_component.py +0 -13
- unit_tests/sources/declarative/extractors/__init__.py +0 -3
- unit_tests/sources/declarative/extractors/test_dpath_extractor.py +0 -55
- unit_tests/sources/declarative/extractors/test_record_filter.py +0 -55
- unit_tests/sources/declarative/extractors/test_record_selector.py +0 -179
- unit_tests/sources/declarative/incremental/__init__.py +0 -0
- unit_tests/sources/declarative/incremental/test_datetime_based_cursor.py +0 -860
- unit_tests/sources/declarative/incremental/test_per_partition_cursor.py +0 -406
- unit_tests/sources/declarative/incremental/test_per_partition_cursor_integration.py +0 -332
- unit_tests/sources/declarative/interpolation/__init__.py +0 -3
- unit_tests/sources/declarative/interpolation/test_filters.py +0 -80
- unit_tests/sources/declarative/interpolation/test_interpolated_boolean.py +0 -40
- unit_tests/sources/declarative/interpolation/test_interpolated_mapping.py +0 -35
- unit_tests/sources/declarative/interpolation/test_interpolated_nested_mapping.py +0 -45
- unit_tests/sources/declarative/interpolation/test_interpolated_string.py +0 -25
- unit_tests/sources/declarative/interpolation/test_jinja.py +0 -240
- unit_tests/sources/declarative/interpolation/test_macros.py +0 -73
- unit_tests/sources/declarative/parsers/__init__.py +0 -3
- unit_tests/sources/declarative/parsers/test_manifest_component_transformer.py +0 -406
- unit_tests/sources/declarative/parsers/test_manifest_reference_resolver.py +0 -139
- unit_tests/sources/declarative/parsers/test_model_to_component_factory.py +0 -1847
- unit_tests/sources/declarative/parsers/testing_components.py +0 -36
- unit_tests/sources/declarative/partition_routers/__init__.py +0 -3
- unit_tests/sources/declarative/partition_routers/test_list_partition_router.py +0 -155
- unit_tests/sources/declarative/partition_routers/test_single_partition_router.py +0 -14
- unit_tests/sources/declarative/partition_routers/test_substream_partition_router.py +0 -404
- unit_tests/sources/declarative/requesters/__init__.py +0 -3
- unit_tests/sources/declarative/requesters/error_handlers/__init__.py +0 -3
- unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/__init__.py +0 -3
- unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_constant_backoff.py +0 -34
- unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_exponential_backoff.py +0 -36
- unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_header_helper.py +0 -38
- unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_time_from_header.py +0 -35
- unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_until_time_from_header.py +0 -64
- unit_tests/sources/declarative/requesters/error_handlers/test_composite_error_handler.py +0 -213
- unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py +0 -178
- unit_tests/sources/declarative/requesters/error_handlers/test_http_response_filter.py +0 -121
- unit_tests/sources/declarative/requesters/error_handlers/test_response_status.py +0 -44
- unit_tests/sources/declarative/requesters/paginators/__init__.py +0 -3
- unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py +0 -64
- unit_tests/sources/declarative/requesters/paginators/test_default_paginator.py +0 -313
- unit_tests/sources/declarative/requesters/paginators/test_no_paginator.py +0 -12
- unit_tests/sources/declarative/requesters/paginators/test_offset_increment.py +0 -58
- unit_tests/sources/declarative/requesters/paginators/test_page_increment.py +0 -70
- unit_tests/sources/declarative/requesters/paginators/test_request_option.py +0 -43
- unit_tests/sources/declarative/requesters/paginators/test_stop_condition.py +0 -105
- unit_tests/sources/declarative/requesters/request_options/__init__.py +0 -3
- unit_tests/sources/declarative/requesters/request_options/test_interpolated_request_options_provider.py +0 -101
- unit_tests/sources/declarative/requesters/test_http_requester.py +0 -974
- unit_tests/sources/declarative/requesters/test_interpolated_request_input_provider.py +0 -32
- unit_tests/sources/declarative/retrievers/__init__.py +0 -3
- unit_tests/sources/declarative/retrievers/test_simple_retriever.py +0 -542
- unit_tests/sources/declarative/schema/__init__.py +0 -6
- unit_tests/sources/declarative/schema/source_test/SourceTest.py +0 -8
- unit_tests/sources/declarative/schema/source_test/__init__.py +0 -3
- unit_tests/sources/declarative/schema/test_default_schema_loader.py +0 -32
- unit_tests/sources/declarative/schema/test_inline_schema_loader.py +0 -19
- unit_tests/sources/declarative/schema/test_json_file_schema_loader.py +0 -26
- unit_tests/sources/declarative/states/__init__.py +0 -3
- unit_tests/sources/declarative/stream_slicers/__init__.py +0 -3
- unit_tests/sources/declarative/stream_slicers/test_cartesian_product_stream_slicer.py +0 -225
- unit_tests/sources/declarative/test_create_partial.py +0 -83
- unit_tests/sources/declarative/test_declarative_stream.py +0 -103
- unit_tests/sources/declarative/test_manifest_declarative_source.py +0 -1260
- unit_tests/sources/declarative/test_types.py +0 -39
- unit_tests/sources/declarative/test_yaml_declarative_source.py +0 -148
- unit_tests/sources/file_based/__init__.py +0 -0
- unit_tests/sources/file_based/availability_strategy/__init__.py +0 -0
- unit_tests/sources/file_based/availability_strategy/test_default_file_based_availability_strategy.py +0 -100
- unit_tests/sources/file_based/config/__init__.py +0 -0
- unit_tests/sources/file_based/config/test_abstract_file_based_spec.py +0 -28
- unit_tests/sources/file_based/config/test_csv_format.py +0 -34
- unit_tests/sources/file_based/config/test_file_based_stream_config.py +0 -84
- unit_tests/sources/file_based/discovery_policy/__init__.py +0 -0
- unit_tests/sources/file_based/discovery_policy/test_default_discovery_policy.py +0 -31
- unit_tests/sources/file_based/file_types/__init__.py +0 -0
- unit_tests/sources/file_based/file_types/test_avro_parser.py +0 -243
- unit_tests/sources/file_based/file_types/test_csv_parser.py +0 -546
- unit_tests/sources/file_based/file_types/test_jsonl_parser.py +0 -158
- unit_tests/sources/file_based/file_types/test_parquet_parser.py +0 -274
- unit_tests/sources/file_based/file_types/test_unstructured_parser.py +0 -593
- unit_tests/sources/file_based/helpers.py +0 -70
- unit_tests/sources/file_based/in_memory_files_source.py +0 -211
- unit_tests/sources/file_based/scenarios/__init__.py +0 -0
- unit_tests/sources/file_based/scenarios/avro_scenarios.py +0 -744
- unit_tests/sources/file_based/scenarios/check_scenarios.py +0 -220
- unit_tests/sources/file_based/scenarios/concurrent_incremental_scenarios.py +0 -2844
- unit_tests/sources/file_based/scenarios/csv_scenarios.py +0 -3105
- unit_tests/sources/file_based/scenarios/file_based_source_builder.py +0 -91
- unit_tests/sources/file_based/scenarios/incremental_scenarios.py +0 -1926
- unit_tests/sources/file_based/scenarios/jsonl_scenarios.py +0 -930
- unit_tests/sources/file_based/scenarios/parquet_scenarios.py +0 -754
- unit_tests/sources/file_based/scenarios/scenario_builder.py +0 -234
- unit_tests/sources/file_based/scenarios/unstructured_scenarios.py +0 -608
- unit_tests/sources/file_based/scenarios/user_input_schema_scenarios.py +0 -746
- unit_tests/sources/file_based/scenarios/validation_policy_scenarios.py +0 -726
- unit_tests/sources/file_based/stream/__init__.py +0 -0
- unit_tests/sources/file_based/stream/concurrent/__init__.py +0 -0
- unit_tests/sources/file_based/stream/concurrent/test_adapters.py +0 -362
- unit_tests/sources/file_based/stream/concurrent/test_file_based_concurrent_cursor.py +0 -458
- unit_tests/sources/file_based/stream/test_default_file_based_cursor.py +0 -310
- unit_tests/sources/file_based/stream/test_default_file_based_stream.py +0 -244
- unit_tests/sources/file_based/test_file_based_scenarios.py +0 -320
- unit_tests/sources/file_based/test_file_based_stream_reader.py +0 -272
- unit_tests/sources/file_based/test_scenarios.py +0 -253
- unit_tests/sources/file_based/test_schema_helpers.py +0 -346
- unit_tests/sources/fixtures/__init__.py +0 -3
- unit_tests/sources/fixtures/source_test_fixture.py +0 -153
- unit_tests/sources/message/__init__.py +0 -0
- unit_tests/sources/message/test_repository.py +0 -153
- unit_tests/sources/streams/__init__.py +0 -0
- unit_tests/sources/streams/concurrent/__init__.py +0 -3
- unit_tests/sources/streams/concurrent/scenarios/__init__.py +0 -3
- unit_tests/sources/streams/concurrent/scenarios/incremental_scenarios.py +0 -250
- unit_tests/sources/streams/concurrent/scenarios/stream_facade_builder.py +0 -140
- unit_tests/sources/streams/concurrent/scenarios/stream_facade_scenarios.py +0 -452
- unit_tests/sources/streams/concurrent/scenarios/test_concurrent_scenarios.py +0 -76
- unit_tests/sources/streams/concurrent/scenarios/thread_based_concurrent_stream_scenarios.py +0 -418
- unit_tests/sources/streams/concurrent/scenarios/thread_based_concurrent_stream_source_builder.py +0 -142
- unit_tests/sources/streams/concurrent/scenarios/utils.py +0 -55
- unit_tests/sources/streams/concurrent/test_adapters.py +0 -380
- unit_tests/sources/streams/concurrent/test_concurrent_read_processor.py +0 -684
- unit_tests/sources/streams/concurrent/test_cursor.py +0 -139
- unit_tests/sources/streams/concurrent/test_datetime_state_converter.py +0 -369
- unit_tests/sources/streams/concurrent/test_default_stream.py +0 -197
- unit_tests/sources/streams/concurrent/test_partition_enqueuer.py +0 -90
- unit_tests/sources/streams/concurrent/test_partition_reader.py +0 -67
- unit_tests/sources/streams/concurrent/test_thread_pool_manager.py +0 -106
- unit_tests/sources/streams/http/__init__.py +0 -0
- unit_tests/sources/streams/http/auth/__init__.py +0 -0
- unit_tests/sources/streams/http/auth/test_auth.py +0 -173
- unit_tests/sources/streams/http/requests_native_auth/__init__.py +0 -0
- unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py +0 -423
- unit_tests/sources/streams/http/test_availability_strategy.py +0 -180
- unit_tests/sources/streams/http/test_http.py +0 -635
- unit_tests/sources/streams/test_availability_strategy.py +0 -70
- unit_tests/sources/streams/test_call_rate.py +0 -300
- unit_tests/sources/streams/test_stream_read.py +0 -405
- unit_tests/sources/streams/test_streams_core.py +0 -184
- unit_tests/sources/test_abstract_source.py +0 -1442
- unit_tests/sources/test_concurrent_source.py +0 -112
- unit_tests/sources/test_config.py +0 -92
- unit_tests/sources/test_connector_state_manager.py +0 -482
- unit_tests/sources/test_http_logger.py +0 -252
- unit_tests/sources/test_integration_source.py +0 -86
- unit_tests/sources/test_source.py +0 -684
- unit_tests/sources/test_source_read.py +0 -460
- unit_tests/test/__init__.py +0 -0
- unit_tests/test/mock_http/__init__.py +0 -0
- unit_tests/test/mock_http/test_matcher.py +0 -53
- unit_tests/test/mock_http/test_mocker.py +0 -214
- unit_tests/test/mock_http/test_request.py +0 -117
- unit_tests/test/mock_http/test_response_builder.py +0 -177
- unit_tests/test/test_entrypoint_wrapper.py +0 -240
- unit_tests/utils/__init__.py +0 -0
- unit_tests/utils/test_datetime_format_inferrer.py +0 -60
- unit_tests/utils/test_mapping_helpers.py +0 -54
- unit_tests/utils/test_message_utils.py +0 -91
- unit_tests/utils/test_rate_limiting.py +0 -26
- unit_tests/utils/test_schema_inferrer.py +0 -202
- unit_tests/utils/test_secret_utils.py +0 -135
- unit_tests/utils/test_stream_status_utils.py +0 -61
- unit_tests/utils/test_traced_exception.py +0 -107
- /airbyte_cdk/sources/{deprecated → declarative/async_job}/__init__.py +0 -0
- {source_declarative_manifest → airbyte_cdk/sources/declarative/migrations}/__init__.py +0 -0
- {unit_tests/destinations → airbyte_cdk/sql}/__init__.py +0 -0
- {unit_tests/singer → airbyte_cdk/sql/_util}/__init__.py +0 -0
- {airbyte_cdk-0.72.1.dist-info → airbyte_cdk-6.17.1.dev1.dist-info}/LICENSE.txt +0 -0
@@ -3,18 +3,31 @@
|
|
3
3
|
#
|
4
4
|
|
5
5
|
from collections import defaultdict
|
6
|
-
from typing import Any, Dict, Mapping, Optional
|
6
|
+
from typing import Any, Dict, List, Mapping, Optional
|
7
7
|
|
8
|
-
from airbyte_cdk.models import AirbyteRecordMessage
|
9
8
|
from genson import SchemaBuilder, SchemaNode
|
10
9
|
from genson.schema.strategies.object import Object
|
11
10
|
from genson.schema.strategies.scalar import Number
|
12
11
|
|
12
|
+
from airbyte_cdk.models import AirbyteRecordMessage
|
13
|
+
|
14
|
+
# schema keywords
|
15
|
+
_TYPE = "type"
|
16
|
+
_NULL_TYPE = "null"
|
17
|
+
_OBJECT_TYPE = "object"
|
18
|
+
_ANY_OF = "anyOf"
|
19
|
+
_ITEMS = "items"
|
20
|
+
_PROPERTIES = "properties"
|
21
|
+
_REQUIRED = "required"
|
22
|
+
|
13
23
|
|
14
24
|
class NoRequiredObj(Object):
|
15
25
|
"""
|
16
26
|
This class has Object behaviour, but it does not generate "required[]" fields
|
17
|
-
every time it parses object. So we
|
27
|
+
every time it parses object. So we don't add unnecessary extra field.
|
28
|
+
|
29
|
+
The logic is that even reading all the data from a source, it does not mean that there can be another record added with those fields as
|
30
|
+
optional. Hence, we make everything nullable.
|
18
31
|
"""
|
19
32
|
|
20
33
|
def to_schema(self) -> Mapping[str, Any]:
|
@@ -41,6 +54,30 @@ class NoRequiredSchemaBuilder(SchemaBuilder):
|
|
41
54
|
InferredSchema = Dict[str, Any]
|
42
55
|
|
43
56
|
|
57
|
+
class SchemaValidationException(Exception):
|
58
|
+
@classmethod
|
59
|
+
def merge_exceptions(
|
60
|
+
cls, exceptions: List["SchemaValidationException"]
|
61
|
+
) -> "SchemaValidationException":
|
62
|
+
# We assume the schema is the same for all SchemaValidationException
|
63
|
+
return SchemaValidationException(
|
64
|
+
exceptions[0].schema,
|
65
|
+
[x for exception in exceptions for x in exception._validation_errors],
|
66
|
+
)
|
67
|
+
|
68
|
+
def __init__(self, schema: InferredSchema, validation_errors: List[Exception]):
|
69
|
+
self._schema = schema
|
70
|
+
self._validation_errors = validation_errors
|
71
|
+
|
72
|
+
@property
|
73
|
+
def schema(self) -> InferredSchema:
|
74
|
+
return self._schema
|
75
|
+
|
76
|
+
@property
|
77
|
+
def validation_errors(self) -> List[str]:
|
78
|
+
return list(map(lambda error: str(error), self._validation_errors))
|
79
|
+
|
80
|
+
|
44
81
|
class SchemaInferrer:
|
45
82
|
"""
|
46
83
|
This class is used to infer a JSON schema which fits all the records passed into it
|
@@ -53,22 +90,54 @@ class SchemaInferrer:
|
|
53
90
|
|
54
91
|
stream_to_builder: Dict[str, SchemaBuilder]
|
55
92
|
|
56
|
-
def __init__(
|
93
|
+
def __init__(
|
94
|
+
self, pk: Optional[List[List[str]]] = None, cursor_field: Optional[List[List[str]]] = None
|
95
|
+
) -> None:
|
57
96
|
self.stream_to_builder = defaultdict(NoRequiredSchemaBuilder)
|
97
|
+
self._pk = [] if pk is None else pk
|
98
|
+
self._cursor_field = [] if cursor_field is None else cursor_field
|
58
99
|
|
59
100
|
def accumulate(self, record: AirbyteRecordMessage) -> None:
|
60
101
|
"""Uses the input record to add to the inferred schemas maintained by this object"""
|
61
102
|
self.stream_to_builder[record.stream].add_object(record.data)
|
62
103
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
104
|
+
def _null_type_in_any_of(self, node: InferredSchema) -> bool:
|
105
|
+
if _ANY_OF in node:
|
106
|
+
return {_TYPE: _NULL_TYPE} in node[_ANY_OF]
|
107
|
+
else:
|
108
|
+
return False
|
109
|
+
|
110
|
+
def _remove_type_from_any_of(self, node: InferredSchema) -> None:
|
111
|
+
if _ANY_OF in node:
|
112
|
+
node.pop(_TYPE, None)
|
113
|
+
|
114
|
+
def _clean_any_of(self, node: InferredSchema) -> None:
|
115
|
+
if len(node[_ANY_OF]) == 2 and self._null_type_in_any_of(node):
|
116
|
+
real_type = (
|
117
|
+
node[_ANY_OF][1] if node[_ANY_OF][0][_TYPE] == _NULL_TYPE else node[_ANY_OF][0]
|
118
|
+
)
|
119
|
+
node.update(real_type)
|
120
|
+
node[_TYPE] = [node[_TYPE], _NULL_TYPE]
|
121
|
+
node.pop(_ANY_OF)
|
122
|
+
# populate `type` for `anyOf` if it's not present to pass all other checks
|
123
|
+
elif len(node[_ANY_OF]) == 2 and not self._null_type_in_any_of(node):
|
124
|
+
node[_TYPE] = [_NULL_TYPE]
|
125
|
+
|
126
|
+
def _clean_properties(self, node: InferredSchema) -> None:
|
127
|
+
for key, value in list(node[_PROPERTIES].items()):
|
128
|
+
if isinstance(value, dict) and value.get(_TYPE, None) == _NULL_TYPE:
|
129
|
+
node[_PROPERTIES].pop(key)
|
130
|
+
else:
|
131
|
+
self._clean(value)
|
132
|
+
|
133
|
+
def _ensure_null_type_on_top(self, node: InferredSchema) -> None:
|
134
|
+
if isinstance(node[_TYPE], list):
|
135
|
+
if _NULL_TYPE in node[_TYPE]:
|
136
|
+
# we want to make sure null is always at the end as it makes schemas more readable
|
137
|
+
node[_TYPE].remove(_NULL_TYPE)
|
138
|
+
node[_TYPE].append(_NULL_TYPE)
|
139
|
+
else:
|
140
|
+
node[_TYPE] = [node[_TYPE], _NULL_TYPE]
|
72
141
|
|
73
142
|
def _clean(self, node: InferredSchema) -> InferredSchema:
|
74
143
|
"""
|
@@ -76,25 +145,126 @@ class SchemaInferrer:
|
|
76
145
|
- remove anyOf if one of them is just a null value
|
77
146
|
- remove properties of type "null"
|
78
147
|
"""
|
148
|
+
|
79
149
|
if isinstance(node, dict):
|
80
|
-
if
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
150
|
+
if _ANY_OF in node:
|
151
|
+
self._clean_any_of(node)
|
152
|
+
|
153
|
+
if _PROPERTIES in node and isinstance(node[_PROPERTIES], dict):
|
154
|
+
self._clean_properties(node)
|
155
|
+
|
156
|
+
if _ITEMS in node:
|
157
|
+
self._clean(node[_ITEMS])
|
158
|
+
|
159
|
+
# this check needs to follow the "anyOf" cleaning as it might populate `type`
|
160
|
+
self._ensure_null_type_on_top(node)
|
161
|
+
|
162
|
+
# remove added `type: ["null"]` for `anyOf` nested node
|
163
|
+
self._remove_type_from_any_of(node)
|
164
|
+
|
165
|
+
return node
|
166
|
+
|
167
|
+
def _add_required_properties(self, node: InferredSchema) -> InferredSchema:
|
168
|
+
"""
|
169
|
+
This method takes properties that should be marked as required (self._pk and self._cursor_field) and travel the schema to mark every
|
170
|
+
node as required.
|
171
|
+
"""
|
172
|
+
# Removing nullable for the root as when we call `_clean`, we make everything nullable
|
173
|
+
node[_TYPE] = _OBJECT_TYPE
|
174
|
+
|
175
|
+
exceptions = []
|
176
|
+
for field in [x for x in [self._pk, self._cursor_field] if x]:
|
177
|
+
try:
|
178
|
+
self._add_fields_as_required(node, field)
|
179
|
+
except SchemaValidationException as exception:
|
180
|
+
exceptions.append(exception)
|
181
|
+
|
182
|
+
if exceptions:
|
183
|
+
raise SchemaValidationException.merge_exceptions(exceptions)
|
184
|
+
|
94
185
|
return node
|
95
186
|
|
187
|
+
def _add_fields_as_required(self, node: InferredSchema, composite_key: List[List[str]]) -> None:
|
188
|
+
"""
|
189
|
+
Take a list of nested keys (this list represents a composite key) and travel the schema to mark every node as required.
|
190
|
+
"""
|
191
|
+
errors: List[Exception] = []
|
192
|
+
|
193
|
+
for path in composite_key:
|
194
|
+
try:
|
195
|
+
self._add_field_as_required(node, path)
|
196
|
+
except ValueError as exception:
|
197
|
+
errors.append(exception)
|
198
|
+
|
199
|
+
if errors:
|
200
|
+
raise SchemaValidationException(node, errors)
|
201
|
+
|
202
|
+
def _add_field_as_required(
|
203
|
+
self, node: InferredSchema, path: List[str], traveled_path: Optional[List[str]] = None
|
204
|
+
) -> None:
|
205
|
+
"""
|
206
|
+
Take a nested key and travel the schema to mark every node as required.
|
207
|
+
"""
|
208
|
+
self._remove_null_from_type(node)
|
209
|
+
if self._is_leaf(path):
|
210
|
+
return
|
211
|
+
|
212
|
+
if not traveled_path:
|
213
|
+
traveled_path = []
|
214
|
+
|
215
|
+
if _PROPERTIES not in node:
|
216
|
+
# This validation is only relevant when `traveled_path` is empty
|
217
|
+
raise ValueError(
|
218
|
+
f"Path {traveled_path} does not refer to an object but is `{node}` and hence {path} can't be marked as required."
|
219
|
+
)
|
220
|
+
|
221
|
+
next_node = path[0]
|
222
|
+
if next_node not in node[_PROPERTIES]:
|
223
|
+
raise ValueError(
|
224
|
+
f"Path {traveled_path} does not have field `{next_node}` in the schema and hence can't be marked as required."
|
225
|
+
)
|
226
|
+
|
227
|
+
if _TYPE not in node:
|
228
|
+
# We do not expect this case to happen but we added a specific error message just in case
|
229
|
+
raise ValueError(
|
230
|
+
f"Unknown schema error: {traveled_path} is expected to have a type but did not. Schema inferrence is probably broken"
|
231
|
+
)
|
232
|
+
|
233
|
+
if node[_TYPE] not in [
|
234
|
+
_OBJECT_TYPE,
|
235
|
+
[_NULL_TYPE, _OBJECT_TYPE],
|
236
|
+
[_OBJECT_TYPE, _NULL_TYPE],
|
237
|
+
]:
|
238
|
+
raise ValueError(
|
239
|
+
f"Path {traveled_path} is expected to be an object but was of type `{node['properties'][next_node]['type']}`"
|
240
|
+
)
|
241
|
+
|
242
|
+
if _REQUIRED not in node or not node[_REQUIRED]:
|
243
|
+
node[_REQUIRED] = [next_node]
|
244
|
+
elif next_node not in node[_REQUIRED]:
|
245
|
+
node[_REQUIRED].append(next_node)
|
246
|
+
|
247
|
+
traveled_path.append(next_node)
|
248
|
+
self._add_field_as_required(node[_PROPERTIES][next_node], path[1:], traveled_path)
|
249
|
+
|
250
|
+
def _is_leaf(self, path: List[str]) -> bool:
|
251
|
+
return len(path) == 0
|
252
|
+
|
253
|
+
def _remove_null_from_type(self, node: InferredSchema) -> None:
|
254
|
+
if isinstance(node[_TYPE], list):
|
255
|
+
if _NULL_TYPE in node[_TYPE]:
|
256
|
+
node[_TYPE].remove(_NULL_TYPE)
|
257
|
+
if len(node[_TYPE]) == 1:
|
258
|
+
node[_TYPE] = node[_TYPE][0]
|
259
|
+
|
96
260
|
def get_stream_schema(self, stream_name: str) -> Optional[InferredSchema]:
|
97
261
|
"""
|
98
262
|
Returns the inferred JSON schema for the specified stream. Might be `None` if there were no records for the given stream name.
|
99
263
|
"""
|
100
|
-
return
|
264
|
+
return (
|
265
|
+
self._add_required_properties(
|
266
|
+
self._clean(self.stream_to_builder[stream_name].to_schema())
|
267
|
+
)
|
268
|
+
if stream_name in self.stream_to_builder
|
269
|
+
else None
|
270
|
+
)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import hashlib
|
2
|
+
import json
|
3
|
+
from typing import Any, Final, Mapping, Optional
|
4
|
+
|
5
|
+
|
6
|
+
class SliceEncoder(json.JSONEncoder):
|
7
|
+
def default(self, obj: Any) -> Any:
|
8
|
+
if hasattr(obj, "__json_serializable__"):
|
9
|
+
return obj.__json_serializable__()
|
10
|
+
|
11
|
+
# Let the base class default method raise the TypeError
|
12
|
+
return super().default(obj)
|
13
|
+
|
14
|
+
|
15
|
+
class SliceHasher:
|
16
|
+
_ENCODING: Final = "utf-8"
|
17
|
+
|
18
|
+
@classmethod
|
19
|
+
def hash(cls, stream_name: str, stream_slice: Optional[Mapping[str, Any]] = None) -> int:
|
20
|
+
if stream_slice:
|
21
|
+
try:
|
22
|
+
s = json.dumps(stream_slice, sort_keys=True, cls=SliceEncoder)
|
23
|
+
hash_input = f"{stream_name}:{s}".encode(cls._ENCODING)
|
24
|
+
except TypeError as e:
|
25
|
+
raise ValueError(f"Failed to serialize stream slice: {e}")
|
26
|
+
else:
|
27
|
+
hash_input = stream_name.encode(cls._ENCODING)
|
28
|
+
|
29
|
+
# Use last 8 bytes as 64-bit integer for better distribution
|
30
|
+
return int.from_bytes(hashlib.sha256(hash_input).digest()[-8:], "big")
|
@@ -4,11 +4,12 @@
|
|
4
4
|
|
5
5
|
import json
|
6
6
|
import re
|
7
|
+
from typing import Any
|
7
8
|
|
8
9
|
from jsonschema import RefResolver
|
9
10
|
|
10
11
|
|
11
|
-
def resolve_refs(schema: dict) -> dict:
|
12
|
+
def resolve_refs(schema: dict[str, Any]) -> dict[str, Any]:
|
12
13
|
"""
|
13
14
|
For spec schemas generated using Pydantic models, the resulting JSON schema can contain refs between object
|
14
15
|
relationships.
|
@@ -17,7 +18,9 @@ def resolve_refs(schema: dict) -> dict:
|
|
17
18
|
str_schema = json.dumps(schema)
|
18
19
|
for ref_block in re.findall(r'{"\$ref": "#\/definitions\/.+?(?="})"}', str_schema):
|
19
20
|
ref = json.loads(ref_block)["$ref"]
|
20
|
-
str_schema = str_schema.replace(
|
21
|
-
|
21
|
+
str_schema = str_schema.replace(
|
22
|
+
ref_block, json.dumps(json_schema_ref_resolver.resolve(ref)[1])
|
23
|
+
)
|
24
|
+
pyschema: dict[str, Any] = json.loads(str_schema)
|
22
25
|
del pyschema["definitions"]
|
23
26
|
return pyschema
|
@@ -4,11 +4,13 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
from datetime import datetime
|
7
|
+
from typing import List, Optional, Union
|
7
8
|
|
8
9
|
from airbyte_cdk.models import (
|
9
10
|
AirbyteMessage,
|
10
11
|
AirbyteStream,
|
11
12
|
AirbyteStreamStatus,
|
13
|
+
AirbyteStreamStatusReason,
|
12
14
|
AirbyteStreamStatusTraceMessage,
|
13
15
|
AirbyteTraceMessage,
|
14
16
|
StreamDescriptor,
|
@@ -17,7 +19,11 @@ from airbyte_cdk.models import (
|
|
17
19
|
from airbyte_cdk.models import Type as MessageType
|
18
20
|
|
19
21
|
|
20
|
-
def as_airbyte_message(
|
22
|
+
def as_airbyte_message(
|
23
|
+
stream: Union[AirbyteStream, StreamDescriptor],
|
24
|
+
current_status: AirbyteStreamStatus,
|
25
|
+
reasons: Optional[List[AirbyteStreamStatusReason]] = None,
|
26
|
+
) -> AirbyteMessage:
|
21
27
|
"""
|
22
28
|
Builds an AirbyteStreamStatusTraceMessage for the provided stream
|
23
29
|
"""
|
@@ -30,6 +36,7 @@ def as_airbyte_message(stream: AirbyteStream, current_status: AirbyteStreamStatu
|
|
30
36
|
stream_status=AirbyteStreamStatusTraceMessage(
|
31
37
|
stream_descriptor=StreamDescriptor(name=stream.name, namespace=stream.namespace),
|
32
38
|
status=current_status,
|
39
|
+
reasons=reasons,
|
33
40
|
),
|
34
41
|
)
|
35
42
|
|
@@ -1,15 +1,17 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
3
|
#
|
4
|
-
|
4
|
+
import time
|
5
5
|
import traceback
|
6
|
-
from
|
7
|
-
|
6
|
+
from typing import Any, Optional
|
7
|
+
|
8
|
+
import orjson
|
8
9
|
|
9
10
|
from airbyte_cdk.models import (
|
10
11
|
AirbyteConnectionStatus,
|
11
12
|
AirbyteErrorTraceMessage,
|
12
13
|
AirbyteMessage,
|
14
|
+
AirbyteMessageSerializer,
|
13
15
|
AirbyteTraceMessage,
|
14
16
|
FailureType,
|
15
17
|
Status,
|
@@ -31,24 +33,32 @@ class AirbyteTracedException(Exception):
|
|
31
33
|
message: Optional[str] = None,
|
32
34
|
failure_type: FailureType = FailureType.system_error,
|
33
35
|
exception: Optional[BaseException] = None,
|
36
|
+
stream_descriptor: Optional[StreamDescriptor] = None,
|
34
37
|
):
|
35
38
|
"""
|
36
39
|
:param internal_message: the internal error that caused the failure
|
37
40
|
:param message: a user-friendly message that indicates the cause of the error
|
38
41
|
:param failure_type: the type of error
|
39
42
|
:param exception: the exception that caused the error, from which the stack trace should be retrieved
|
43
|
+
:param stream_descriptor: describe the stream from which the exception comes from
|
40
44
|
"""
|
41
45
|
self.internal_message = internal_message
|
42
46
|
self.message = message
|
43
47
|
self.failure_type = failure_type
|
44
48
|
self._exception = exception
|
49
|
+
self._stream_descriptor = stream_descriptor
|
45
50
|
super().__init__(internal_message)
|
46
51
|
|
47
|
-
def as_airbyte_message(
|
52
|
+
def as_airbyte_message(
|
53
|
+
self, stream_descriptor: Optional[StreamDescriptor] = None
|
54
|
+
) -> AirbyteMessage:
|
48
55
|
"""
|
49
56
|
Builds an AirbyteTraceMessage from the exception
|
57
|
+
|
58
|
+
:param stream_descriptor is deprecated, please use the stream_description in `__init__ or `from_exception`. If many
|
59
|
+
stream_descriptors are defined, the one from `as_airbyte_message` will be discarded.
|
50
60
|
"""
|
51
|
-
now_millis =
|
61
|
+
now_millis = time.time_ns() // 1_000_000
|
52
62
|
|
53
63
|
trace_exc = self._exception or self
|
54
64
|
stack_trace_str = "".join(traceback.TracebackException.from_exception(trace_exc).format())
|
@@ -57,49 +67,79 @@ class AirbyteTracedException(Exception):
|
|
57
67
|
type=TraceType.ERROR,
|
58
68
|
emitted_at=now_millis,
|
59
69
|
error=AirbyteErrorTraceMessage(
|
60
|
-
message=self.message
|
70
|
+
message=self.message
|
71
|
+
or "Something went wrong in the connector. See the logs for more details.",
|
61
72
|
internal_message=self.internal_message,
|
62
73
|
failure_type=self.failure_type,
|
63
74
|
stack_trace=stack_trace_str,
|
64
|
-
stream_descriptor=
|
75
|
+
stream_descriptor=self._stream_descriptor
|
76
|
+
if self._stream_descriptor is not None
|
77
|
+
else stream_descriptor,
|
65
78
|
),
|
66
79
|
)
|
67
80
|
|
68
81
|
return AirbyteMessage(type=MessageType.TRACE, trace=trace_message)
|
69
82
|
|
70
|
-
def as_connection_status_message(self) -> AirbyteMessage:
|
83
|
+
def as_connection_status_message(self) -> Optional[AirbyteMessage]:
|
71
84
|
if self.failure_type == FailureType.config_error:
|
72
|
-
|
73
|
-
type=MessageType.CONNECTION_STATUS,
|
85
|
+
return AirbyteMessage(
|
86
|
+
type=MessageType.CONNECTION_STATUS,
|
87
|
+
connectionStatus=AirbyteConnectionStatus(
|
88
|
+
status=Status.FAILED, message=self.message
|
89
|
+
),
|
74
90
|
)
|
75
|
-
|
91
|
+
return None
|
76
92
|
|
77
93
|
def emit_message(self) -> None:
|
78
94
|
"""
|
79
95
|
Prints the exception as an AirbyteTraceMessage.
|
80
96
|
Note that this will be called automatically on uncaught exceptions when using the airbyte_cdk entrypoint.
|
81
97
|
"""
|
82
|
-
message = self.as_airbyte_message().
|
98
|
+
message = orjson.dumps(AirbyteMessageSerializer.dump(self.as_airbyte_message())).decode()
|
83
99
|
filtered_message = filter_secrets(message)
|
84
100
|
print(filtered_message)
|
85
101
|
|
86
102
|
@classmethod
|
87
|
-
def from_exception(
|
103
|
+
def from_exception(
|
104
|
+
cls,
|
105
|
+
exc: BaseException,
|
106
|
+
stream_descriptor: Optional[StreamDescriptor] = None,
|
107
|
+
*args: Any,
|
108
|
+
**kwargs: Any,
|
109
|
+
) -> "AirbyteTracedException":
|
88
110
|
"""
|
89
111
|
Helper to create an AirbyteTracedException from an existing exception
|
90
112
|
:param exc: the exception that caused the error
|
113
|
+
:param stream_descriptor: describe the stream from which the exception comes from
|
91
114
|
"""
|
92
|
-
return cls(
|
115
|
+
return cls(
|
116
|
+
internal_message=str(exc),
|
117
|
+
exception=exc,
|
118
|
+
stream_descriptor=stream_descriptor,
|
119
|
+
*args,
|
120
|
+
**kwargs,
|
121
|
+
) # type: ignore # ignoring because of args and kwargs
|
93
122
|
|
94
|
-
def as_sanitized_airbyte_message(
|
123
|
+
def as_sanitized_airbyte_message(
|
124
|
+
self, stream_descriptor: Optional[StreamDescriptor] = None
|
125
|
+
) -> AirbyteMessage:
|
95
126
|
"""
|
96
127
|
Builds an AirbyteTraceMessage from the exception and sanitizes any secrets from the message body
|
128
|
+
|
129
|
+
:param stream_descriptor is deprecated, please use the stream_description in `__init__ or `from_exception`. If many
|
130
|
+
stream_descriptors are defined, the one from `as_sanitized_airbyte_message` will be discarded.
|
97
131
|
"""
|
98
132
|
error_message = self.as_airbyte_message(stream_descriptor=stream_descriptor)
|
99
|
-
if error_message.trace.error.message:
|
100
|
-
error_message.trace.error.message = filter_secrets(
|
101
|
-
|
102
|
-
|
103
|
-
if error_message.trace.error.
|
104
|
-
error_message.trace.error.
|
133
|
+
if error_message.trace.error.message: # type: ignore[union-attr] # AirbyteMessage with MessageType.TRACE has AirbyteTraceMessage
|
134
|
+
error_message.trace.error.message = filter_secrets( # type: ignore[union-attr]
|
135
|
+
error_message.trace.error.message, # type: ignore[union-attr]
|
136
|
+
)
|
137
|
+
if error_message.trace.error.internal_message: # type: ignore[union-attr] # AirbyteMessage with MessageType.TRACE has AirbyteTraceMessage
|
138
|
+
error_message.trace.error.internal_message = filter_secrets( # type: ignore[union-attr] # AirbyteMessage with MessageType.TRACE has AirbyteTraceMessage
|
139
|
+
error_message.trace.error.internal_message # type: ignore[union-attr] # AirbyteMessage with MessageType.TRACE has AirbyteTraceMessage
|
140
|
+
)
|
141
|
+
if error_message.trace.error.stack_trace: # type: ignore[union-attr] # AirbyteMessage with MessageType.TRACE has AirbyteTraceMessage
|
142
|
+
error_message.trace.error.stack_trace = filter_secrets( # type: ignore[union-attr] # AirbyteMessage with MessageType.TRACE has AirbyteTraceMessage
|
143
|
+
error_message.trace.error.stack_trace # type: ignore[union-attr] # AirbyteMessage with MessageType.TRACE has AirbyteTraceMessage
|
144
|
+
)
|
105
145
|
return error_message
|
@@ -0,0 +1,109 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: airbyte-cdk
|
3
|
+
Version: 6.17.1.dev1
|
4
|
+
Summary: A framework for writing Airbyte Connectors.
|
5
|
+
License: MIT
|
6
|
+
Keywords: airbyte,connector-development-kit,cdk
|
7
|
+
Author: Airbyte
|
8
|
+
Author-email: contact@airbyte.io
|
9
|
+
Requires-Python: >=3.10,<3.13
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
11
|
+
Classifier: Intended Audience :: Developers
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
19
|
+
Provides-Extra: file-based
|
20
|
+
Provides-Extra: sql
|
21
|
+
Provides-Extra: vector-db-based
|
22
|
+
Requires-Dist: Jinja2 (>=3.1.2,<3.2.0)
|
23
|
+
Requires-Dist: PyYAML (>=6.0.1,<7.0.0)
|
24
|
+
Requires-Dist: Unidecode (>=1.3,<2.0)
|
25
|
+
Requires-Dist: airbyte-protocol-models-dataclasses (>=0.14,<0.15)
|
26
|
+
Requires-Dist: avro (>=1.11.2,<1.12.0) ; extra == "file-based"
|
27
|
+
Requires-Dist: backoff
|
28
|
+
Requires-Dist: cachetools
|
29
|
+
Requires-Dist: cohere (==4.21) ; extra == "vector-db-based"
|
30
|
+
Requires-Dist: cryptography (>=42.0.5,<44.0.0)
|
31
|
+
Requires-Dist: dpath (>=2.1.6,<3.0.0)
|
32
|
+
Requires-Dist: dunamai (>=1.22.0,<2.0.0)
|
33
|
+
Requires-Dist: fastavro (>=1.8.0,<1.9.0) ; extra == "file-based"
|
34
|
+
Requires-Dist: genson (==1.3.0)
|
35
|
+
Requires-Dist: isodate (>=0.6.1,<0.7.0)
|
36
|
+
Requires-Dist: jsonref (>=0.2,<0.3)
|
37
|
+
Requires-Dist: jsonschema (>=4.17.3,<4.18.0)
|
38
|
+
Requires-Dist: langchain (==0.1.16) ; extra == "vector-db-based"
|
39
|
+
Requires-Dist: langchain_core (==0.1.42)
|
40
|
+
Requires-Dist: markdown ; extra == "file-based"
|
41
|
+
Requires-Dist: nltk (==3.9.1)
|
42
|
+
Requires-Dist: numpy (<2)
|
43
|
+
Requires-Dist: openai[embeddings] (==0.27.9) ; extra == "vector-db-based"
|
44
|
+
Requires-Dist: orjson (>=3.10.7,<4.0.0)
|
45
|
+
Requires-Dist: pandas (==2.2.2)
|
46
|
+
Requires-Dist: pdf2image (==1.16.3) ; extra == "file-based"
|
47
|
+
Requires-Dist: pdfminer.six (==20221105) ; extra == "file-based"
|
48
|
+
Requires-Dist: pendulum (<3.0.0)
|
49
|
+
Requires-Dist: psutil (==6.1.0)
|
50
|
+
Requires-Dist: pyarrow (>=15.0.0,<15.1.0) ; extra == "file-based"
|
51
|
+
Requires-Dist: pydantic (>=2.7,<3.0)
|
52
|
+
Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
|
53
|
+
Requires-Dist: pyrate-limiter (>=3.1.0,<3.2.0)
|
54
|
+
Requires-Dist: pytesseract (==0.3.10) ; extra == "file-based"
|
55
|
+
Requires-Dist: python-calamine (==0.2.3) ; extra == "file-based"
|
56
|
+
Requires-Dist: python-dateutil
|
57
|
+
Requires-Dist: python-snappy (==0.7.3) ; extra == "file-based"
|
58
|
+
Requires-Dist: python-ulid (>=3.0.0,<4.0.0)
|
59
|
+
Requires-Dist: pytz (==2024.2)
|
60
|
+
Requires-Dist: rapidfuzz (>=3.10.1,<4.0.0)
|
61
|
+
Requires-Dist: requests
|
62
|
+
Requires-Dist: requests_cache
|
63
|
+
Requires-Dist: serpyco-rs (>=1.10.2,<2.0.0)
|
64
|
+
Requires-Dist: sqlalchemy (>=2.0,<3.0,!=2.0.36) ; extra == "sql"
|
65
|
+
Requires-Dist: tiktoken (==0.8.0) ; extra == "vector-db-based"
|
66
|
+
Requires-Dist: unstructured.pytesseract (>=0.3.12) ; extra == "file-based"
|
67
|
+
Requires-Dist: unstructured[docx,pptx] (==0.10.27) ; extra == "file-based"
|
68
|
+
Requires-Dist: wcmatch (==10.0)
|
69
|
+
Requires-Dist: xmltodict (>=0.13.0,<0.14.0)
|
70
|
+
Project-URL: Documentation, https://docs.airbyte.io/
|
71
|
+
Project-URL: Homepage, https://airbyte.com
|
72
|
+
Project-URL: Repository, https://github.com/airbytehq/airbyte-python-cdk
|
73
|
+
Description-Content-Type: text/markdown
|
74
|
+
|
75
|
+
# Airbyte Python CDK and Low-Code CDK
|
76
|
+
|
77
|
+
Airbyte Python CDK is a framework for building Airbyte API Source Connectors. It provides a set of
|
78
|
+
classes and helpers that make it easy to build a connector against an HTTP API (REST, GraphQL, etc),
|
79
|
+
or a generic Python source connector.
|
80
|
+
|
81
|
+
## Building Connectors with the CDK
|
82
|
+
|
83
|
+
If you're looking to build a connector, we highly recommend that you first
|
84
|
+
[start with the Connector Builder](https://docs.airbyte.com/connector-development/connector-builder-ui/overview).
|
85
|
+
It should be enough for 90% connectors out there. For more flexible and complex connectors, use the
|
86
|
+
[low-code CDK and `SourceDeclarativeManifest`](https://docs.airbyte.com/connector-development/config-based/low-code-cdk-overview).
|
87
|
+
|
88
|
+
For more information on building connectors, please see the [Connector Development](https://docs.airbyte.com/connector-development/) guide on [docs.airbyte.com](https://docs.airbyte.com).
|
89
|
+
|
90
|
+
## Python CDK Overview
|
91
|
+
|
92
|
+
Airbyte CDK code is within `airbyte_cdk` directory. Here's a high level overview of what's inside:
|
93
|
+
|
94
|
+
- `airbyte_cdk/connector_builder`. Internal wrapper that helps the Connector Builder platform run a declarative manifest (low-code connector). You should not use this code directly. If you need to run a `SourceDeclarativeManifest`, take a look at [`source-declarative-manifest`](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-declarative-manifest) connector implementation instead.
|
95
|
+
- `airbyte_cdk/cli/source_declarative_manifest`. This module defines the `source-declarative-manifest` (aka "SDM") connector execution logic and associated CLI.
|
96
|
+
- `airbyte_cdk/destinations`. Basic Destination connector support! If you're building a Destination connector in Python, try that. Some of our vector DB destinations like `destination-pinecone` are using that code.
|
97
|
+
- `airbyte_cdk/models` expose `airbyte_protocol.models` as a part of `airbyte_cdk` package.
|
98
|
+
- `airbyte_cdk/sources/concurrent_source` is the Concurrent CDK implementation. It supports reading data from streams concurrently per slice / partition, useful for connectors with high throughput and high number of records.
|
99
|
+
- `airbyte_cdk/sources/declarative` is the low-code CDK. It works on top of Airbyte Python CDK, but provides a declarative manifest language to define streams, operations, etc. This makes it easier to build connectors without writing Python code.
|
100
|
+
- `airbyte_cdk/sources/file_based` is the CDK for file-based sources. Examples include S3, Azure, GCS, etc.
|
101
|
+
|
102
|
+
## Contributing
|
103
|
+
|
104
|
+
For instructions on how to contribute, please see our [Contributing Guide](docs/CONTRIBUTING.md).
|
105
|
+
|
106
|
+
## Release Management
|
107
|
+
|
108
|
+
Please see the [Release Management](docs/RELEASES.md) guide for information on how to perform releases and pre-releases.
|
109
|
+
|