airbyte-cdk 6.45.2__py3-none-any.whl → 6.45.2.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.
@@ -2054,6 +2054,7 @@ class ModelToComponentFactory:
2054
2054
  config: Config,
2055
2055
  *,
2056
2056
  url_base: str,
2057
+ extractor_model: Optional[Union[CustomRecordExtractorModel, DpathExtractorModel]] = None,
2057
2058
  decoder: Optional[Decoder] = None,
2058
2059
  cursor_used_for_stop_condition: Optional[DeclarativeCursor] = None,
2059
2060
  ) -> Union[DefaultPaginator, PaginatorTestReadDecorator]:
@@ -2075,7 +2076,10 @@ class ModelToComponentFactory:
2075
2076
  else None
2076
2077
  )
2077
2078
  pagination_strategy = self._create_component_from_model(
2078
- model=model.pagination_strategy, config=config, decoder=decoder_to_use
2079
+ model=model.pagination_strategy,
2080
+ config=config,
2081
+ decoder=decoder_to_use,
2082
+ extractor_model=extractor_model,
2079
2083
  )
2080
2084
  if cursor_used_for_stop_condition:
2081
2085
  pagination_strategy = StopConditionPaginationStrategyDecorator(
@@ -2572,7 +2576,12 @@ class ModelToComponentFactory:
2572
2576
  )
2573
2577
 
2574
2578
  def create_offset_increment(
2575
- self, model: OffsetIncrementModel, config: Config, decoder: Decoder, **kwargs: Any
2579
+ self,
2580
+ model: OffsetIncrementModel,
2581
+ config: Config,
2582
+ decoder: Decoder,
2583
+ extractor_model: Optional[Union[CustomRecordExtractorModel, DpathExtractorModel]] = None,
2584
+ **kwargs: Any,
2576
2585
  ) -> OffsetIncrement:
2577
2586
  if isinstance(decoder, PaginationDecoderDecorator):
2578
2587
  inner_decoder = decoder.decoder
@@ -2587,10 +2596,24 @@ class ModelToComponentFactory:
2587
2596
  self._UNSUPPORTED_DECODER_ERROR.format(decoder_type=type(inner_decoder))
2588
2597
  )
2589
2598
 
2599
+ # Ideally we would instantiate the runtime extractor from highest most level (in this case the SimpleRetriever)
2600
+ # so that it can be shared by OffSetIncrement and RecordSelector. However, due to how we instantiate the
2601
+ # decoder with various decorators here, but not in create_record_selector, it is simpler to retain existing
2602
+ # behavior by having two separate extractors with identical behavior since they use the same extractor model.
2603
+ # When we have more time to investigate we can look into reusing the same component.
2604
+ extractor = (
2605
+ self._create_component_from_model(
2606
+ model=extractor_model, config=config, decoder=decoder_to_use
2607
+ )
2608
+ if extractor_model
2609
+ else None
2610
+ )
2611
+
2590
2612
  return OffsetIncrement(
2591
2613
  page_size=model.page_size,
2592
2614
  config=config,
2593
2615
  decoder=decoder_to_use,
2616
+ extractor=extractor,
2594
2617
  inject_on_first_request=model.inject_on_first_request or False,
2595
2618
  parameters=model.parameters or {},
2596
2619
  )
@@ -2954,6 +2977,7 @@ class ModelToComponentFactory:
2954
2977
  model=model.paginator,
2955
2978
  config=config,
2956
2979
  url_base=url_base,
2980
+ extractor_model=model.record_selector.extractor,
2957
2981
  decoder=decoder,
2958
2982
  cursor_used_for_stop_condition=cursor_used_for_stop_condition,
2959
2983
  )
@@ -12,6 +12,7 @@ from airbyte_cdk.sources.declarative.decoders import (
12
12
  JsonDecoder,
13
13
  PaginationDecoderDecorator,
14
14
  )
15
+ from airbyte_cdk.sources.declarative.extractors.dpath_extractor import RecordExtractor
15
16
  from airbyte_cdk.sources.declarative.interpolation import InterpolatedString
16
17
  from airbyte_cdk.sources.declarative.requesters.paginators.strategies.pagination_strategy import (
17
18
  PaginationStrategy,
@@ -46,6 +47,7 @@ class OffsetIncrement(PaginationStrategy):
46
47
  config: Config
47
48
  page_size: Optional[Union[str, int]]
48
49
  parameters: InitVar[Mapping[str, Any]]
50
+ extractor: Optional[RecordExtractor]
49
51
  decoder: Decoder = field(
50
52
  default_factory=lambda: PaginationDecoderDecorator(decoder=JsonDecoder(parameters={}))
51
53
  )
@@ -75,6 +77,14 @@ class OffsetIncrement(PaginationStrategy):
75
77
  ) -> Optional[Any]:
76
78
  decoded_response = next(self.decoder.decode(response))
77
79
 
80
+ if self.extractor:
81
+ page_size_from_response = len(list(self.extractor.extract_records(response=response)))
82
+ # The extractor could return 0 records which is valid, but evaluates to False. Our fallback in other
83
+ # cases as the best effort option is to use the incoming last_page_size
84
+ last_page_size = (
85
+ page_size_from_response if page_size_from_response is not None else last_page_size
86
+ )
87
+
78
88
  # Stop paginating when there are fewer records than the page size or the current page has no records
79
89
  if (
80
90
  self._page_size
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: airbyte-cdk
3
- Version: 6.45.2
3
+ Version: 6.45.2.dev0
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  Home-page: https://airbyte.com
6
6
  License: MIT
@@ -120,7 +120,7 @@ airbyte_cdk/sources/declarative/parsers/custom_code_compiler.py,sha256=nlVvHC511
120
120
  airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
121
121
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=4C15MKV-zOrMVQAm4FyohDsrJUBCSpMv5tZw0SK3aeI,9685
122
122
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
123
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=Qim2qR64SKWbxD-Au0KAB3fLf6G2YfppUv3Q0w4QYtE,158619
123
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=z02SNalrYrgU8R2KUk9vEEd1c503d1LjQ28mxR8ZKoo,159800
124
124
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=TBC9AkGaUqHm2IKHMPN6punBIcY5tWGULowcLoAVkfw,1109
125
125
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=VelO7zKqKtzMJ35jyFeg0ypJLQC0plqqIBNXoBW1G2E,3001
126
126
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
@@ -152,7 +152,7 @@ airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py,sha256=b1
152
152
  airbyte_cdk/sources/declarative/requesters/paginators/paginator.py,sha256=TzJF1Q-CFlsHF9lMSfmnGCxRYm9_UQCmBcHYQpc7F30,2376
153
153
  airbyte_cdk/sources/declarative/requesters/paginators/strategies/__init__.py,sha256=2gly8fuZpDNwtu1Qg6oE2jBLGqQRdzSLJdnpk_iDV6I,767
154
154
  airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py,sha256=cOURIXaJLCGQfrDP9A7mtSKIb9rVx7WU1V4dvcEc6sw,3897
155
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py,sha256=WvGt_DTFcAgTR-NHrlrR7B71yG-L6jmfW-Gwm9iYzjY,3624
155
+ airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py,sha256=mJ14vcdCpD9rwYdj1Wi6GRzwnOF2yymlQnkjUgGDXmE,4220
156
156
  airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py,sha256=Z2i6a-oKMmOTxHxsTVSnyaShkJ3u8xZw1xIJdx2yxss,2731
157
157
  airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py,sha256=ZBshGQNr5Bb_V8dqnWRISqdXFcjm1CKIXnlfbRhNl8g,1308
158
158
  airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py,sha256=LoKXdUbSgHEtSwtA8DFrnX6SpQbRVVwreY8NguTKTcI,2229
@@ -366,9 +366,9 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EDxgROHDbfG-QKQb59m7h_7crN1tRiawdf5uU7G
366
366
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
367
367
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
368
368
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
369
- airbyte_cdk-6.45.2.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
370
- airbyte_cdk-6.45.2.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
371
- airbyte_cdk-6.45.2.dist-info/METADATA,sha256=ExjYmn0ey8As8Ry3HIBXVXYN1a3dJzMC75DENXvP5hQ,6071
372
- airbyte_cdk-6.45.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
373
- airbyte_cdk-6.45.2.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
374
- airbyte_cdk-6.45.2.dist-info/RECORD,,
369
+ airbyte_cdk-6.45.2.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
370
+ airbyte_cdk-6.45.2.dev0.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
371
+ airbyte_cdk-6.45.2.dev0.dist-info/METADATA,sha256=FBIOxTkDVKCoh9XZPVzJPXcHEh0tLQ1hjBIYpIDI7TQ,6076
372
+ airbyte_cdk-6.45.2.dev0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
373
+ airbyte_cdk-6.45.2.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
374
+ airbyte_cdk-6.45.2.dev0.dist-info/RECORD,,