airbyte-cdk 6.12.3__py3-none-any.whl → 6.12.4.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. airbyte_cdk/sources/declarative/auth/oauth.py +12 -27
  2. airbyte_cdk/sources/declarative/concurrent_declarative_source.py +57 -0
  3. airbyte_cdk/sources/declarative/declarative_component_schema.yaml +1 -23
  4. airbyte_cdk/sources/declarative/extractors/record_filter.py +3 -5
  5. airbyte_cdk/sources/declarative/incremental/__init__.py +3 -0
  6. airbyte_cdk/sources/declarative/incremental/concurrent_partition_cursor.py +344 -0
  7. airbyte_cdk/sources/declarative/incremental/per_partition_cursor.py +14 -0
  8. airbyte_cdk/sources/declarative/models/declarative_component_schema.py +2 -25
  9. airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +80 -53
  10. airbyte_cdk/sources/declarative/partition_routers/__init__.py +1 -9
  11. airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py +14 -20
  12. airbyte_cdk/sources/declarative/retrievers/async_retriever.py +31 -8
  13. airbyte_cdk/sources/declarative/retrievers/simple_retriever.py +1 -1
  14. airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py +3 -20
  15. airbyte_cdk/sources/streams/concurrent/cursor.py +1 -0
  16. airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +3 -12
  17. {airbyte_cdk-6.12.3.dist-info → airbyte_cdk-6.12.4.dev0.dist-info}/METADATA +2 -2
  18. {airbyte_cdk-6.12.3.dist-info → airbyte_cdk-6.12.4.dev0.dist-info}/RECORD +21 -21
  19. airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py +0 -65
  20. {airbyte_cdk-6.12.3.dist-info → airbyte_cdk-6.12.4.dev0.dist-info}/LICENSE.txt +0 -0
  21. {airbyte_cdk-6.12.3.dist-info → airbyte_cdk-6.12.4.dev0.dist-info}/WHEEL +0 -0
  22. {airbyte_cdk-6.12.3.dist-info → airbyte_cdk-6.12.4.dev0.dist-info}/entry_points.txt +0 -0
@@ -1,65 +0,0 @@
1
- # Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2
-
3
- from dataclasses import InitVar, dataclass, field
4
- from typing import Any, Callable, Iterable, Mapping, Optional
5
-
6
- from airbyte_cdk.models import FailureType
7
- from airbyte_cdk.sources.declarative.async_job.job_orchestrator import (
8
- AsyncJobOrchestrator,
9
- AsyncPartition,
10
- )
11
- from airbyte_cdk.sources.declarative.partition_routers.single_partition_router import (
12
- SinglePartitionRouter,
13
- )
14
- from airbyte_cdk.sources.streams.concurrent.partitions.stream_slicer import StreamSlicer
15
- from airbyte_cdk.sources.types import Config, StreamSlice
16
- from airbyte_cdk.utils.traced_exception import AirbyteTracedException
17
-
18
-
19
- @dataclass
20
- class AsyncJobPartitionRouter(StreamSlicer):
21
- """
22
- Partition router that creates async jobs in a source API, periodically polls for job
23
- completion, and supplies the completed job URL locations as stream slices so that
24
- records can be extracted.
25
- """
26
-
27
- config: Config
28
- parameters: InitVar[Mapping[str, Any]]
29
- job_orchestrator_factory: Callable[[Iterable[StreamSlice]], AsyncJobOrchestrator]
30
- stream_slicer: StreamSlicer = field(
31
- default_factory=lambda: SinglePartitionRouter(parameters={})
32
- )
33
-
34
- def __post_init__(self, parameters: Mapping[str, Any]) -> None:
35
- self._job_orchestrator_factory = self.job_orchestrator_factory
36
- self._job_orchestrator: Optional[AsyncJobOrchestrator] = None
37
- self._parameters = parameters
38
-
39
- def stream_slices(self) -> Iterable[StreamSlice]:
40
- slices = self.stream_slicer.stream_slices()
41
- self._job_orchestrator = self._job_orchestrator_factory(slices)
42
-
43
- for completed_partition in self._job_orchestrator.create_and_get_completed_partitions():
44
- yield StreamSlice(
45
- partition=dict(completed_partition.stream_slice.partition)
46
- | {"partition": completed_partition},
47
- cursor_slice=completed_partition.stream_slice.cursor_slice,
48
- )
49
-
50
- def fetch_records(self, partition: AsyncPartition) -> Iterable[Mapping[str, Any]]:
51
- """
52
- This method of fetching records extends beyond what a PartitionRouter/StreamSlicer should
53
- be responsible for. However, this was added in because the JobOrchestrator is required to
54
- retrieve records. And without defining fetch_records() on this class, we're stuck with either
55
- passing the JobOrchestrator to the AsyncRetriever or storing it on multiple classes.
56
- """
57
-
58
- if not self._job_orchestrator:
59
- raise AirbyteTracedException(
60
- message="Invalid state within AsyncJobRetriever. Please contact Airbyte Support",
61
- internal_message="AsyncPartitionRepository is expected to be accessed only after `stream_slices`",
62
- failure_type=FailureType.system_error,
63
- )
64
-
65
- return self._job_orchestrator.fetch_records(partition=partition)