airbyte-cdk 6.45.3__py3-none-any.whl → 6.45.4__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.
@@ -2066,6 +2066,7 @@ class ModelToComponentFactory:
2066
2066
  config: Config,
2067
2067
  *,
2068
2068
  url_base: str,
2069
+ extractor_model: Optional[Union[CustomRecordExtractorModel, DpathExtractorModel]] = None,
2069
2070
  decoder: Optional[Decoder] = None,
2070
2071
  cursor_used_for_stop_condition: Optional[DeclarativeCursor] = None,
2071
2072
  ) -> Union[DefaultPaginator, PaginatorTestReadDecorator]:
@@ -2087,7 +2088,10 @@ class ModelToComponentFactory:
2087
2088
  else None
2088
2089
  )
2089
2090
  pagination_strategy = self._create_component_from_model(
2090
- model=model.pagination_strategy, config=config, decoder=decoder_to_use
2091
+ model=model.pagination_strategy,
2092
+ config=config,
2093
+ decoder=decoder_to_use,
2094
+ extractor_model=extractor_model,
2091
2095
  )
2092
2096
  if cursor_used_for_stop_condition:
2093
2097
  pagination_strategy = StopConditionPaginationStrategyDecorator(
@@ -2584,7 +2588,12 @@ class ModelToComponentFactory:
2584
2588
  )
2585
2589
 
2586
2590
  def create_offset_increment(
2587
- self, model: OffsetIncrementModel, config: Config, decoder: Decoder, **kwargs: Any
2591
+ self,
2592
+ model: OffsetIncrementModel,
2593
+ config: Config,
2594
+ decoder: Decoder,
2595
+ extractor_model: Optional[Union[CustomRecordExtractorModel, DpathExtractorModel]] = None,
2596
+ **kwargs: Any,
2588
2597
  ) -> OffsetIncrement:
2589
2598
  if isinstance(decoder, PaginationDecoderDecorator):
2590
2599
  inner_decoder = decoder.decoder
@@ -2599,10 +2608,24 @@ class ModelToComponentFactory:
2599
2608
  self._UNSUPPORTED_DECODER_ERROR.format(decoder_type=type(inner_decoder))
2600
2609
  )
2601
2610
 
2611
+ # Ideally we would instantiate the runtime extractor from highest most level (in this case the SimpleRetriever)
2612
+ # so that it can be shared by OffSetIncrement and RecordSelector. However, due to how we instantiate the
2613
+ # decoder with various decorators here, but not in create_record_selector, it is simpler to retain existing
2614
+ # behavior by having two separate extractors with identical behavior since they use the same extractor model.
2615
+ # When we have more time to investigate we can look into reusing the same component.
2616
+ extractor = (
2617
+ self._create_component_from_model(
2618
+ model=extractor_model, config=config, decoder=decoder_to_use
2619
+ )
2620
+ if extractor_model
2621
+ else None
2622
+ )
2623
+
2602
2624
  return OffsetIncrement(
2603
2625
  page_size=model.page_size,
2604
2626
  config=config,
2605
2627
  decoder=decoder_to_use,
2628
+ extractor=extractor,
2606
2629
  inject_on_first_request=model.inject_on_first_request or False,
2607
2630
  parameters=model.parameters or {},
2608
2631
  )
@@ -2966,6 +2989,7 @@ class ModelToComponentFactory:
2966
2989
  model=model.paginator,
2967
2990
  config=config,
2968
2991
  url_base=url_base,
2992
+ extractor_model=model.record_selector.extractor,
2969
2993
  decoder=decoder,
2970
2994
  cursor_used_for_stop_condition=cursor_used_for_stop_condition,
2971
2995
  )
@@ -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.3
3
+ Version: 6.45.4
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=mgsar58RvTIhRjlgqjKaf7jOvDM5KiLhjkO7-w-x47I,159047
123
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=zNVn5rLsMT_6F6KgaQKHCzqb8Vbj2yqlQimtTP2VgpY,160228
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.3.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
370
- airbyte_cdk-6.45.3.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
371
- airbyte_cdk-6.45.3.dist-info/METADATA,sha256=wuKgATda_WotQz9zJ4tm3rTUGus73PALPun_UWt_iV0,6071
372
- airbyte_cdk-6.45.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
373
- airbyte_cdk-6.45.3.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
374
- airbyte_cdk-6.45.3.dist-info/RECORD,,
369
+ airbyte_cdk-6.45.4.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
370
+ airbyte_cdk-6.45.4.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
371
+ airbyte_cdk-6.45.4.dist-info/METADATA,sha256=fM30_Gv7VY1C-VVSUkzaUTxCKyV22fZkofniVriIfnE,6071
372
+ airbyte_cdk-6.45.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
373
+ airbyte_cdk-6.45.4.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
374
+ airbyte_cdk-6.45.4.dist-info/RECORD,,