airbyte-cdk 7.1.0__py3-none-any.whl → 7.1.1__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.
@@ -1264,22 +1264,12 @@ class ModelToComponentFactory:
1264
1264
  component_definition: ComponentDefinition,
1265
1265
  stream_name: str,
1266
1266
  stream_namespace: Optional[str],
1267
+ stream_state: MutableMapping[str, Any],
1267
1268
  config: Config,
1268
1269
  message_repository: Optional[MessageRepository] = None,
1269
1270
  runtime_lookback_window: Optional[datetime.timedelta] = None,
1270
- stream_state_migrations: Optional[List[Any]] = None,
1271
1271
  **kwargs: Any,
1272
1272
  ) -> ConcurrentCursor:
1273
- # Per-partition incremental streams can dynamically create child cursors which will pass their current
1274
- # state via the stream_state keyword argument. Incremental syncs without parent streams use the
1275
- # incoming state and connector_state_manager that is initialized when the component factory is created
1276
- stream_state = (
1277
- self._connector_state_manager.get_stream_state(stream_name, stream_namespace)
1278
- if "stream_state" not in kwargs
1279
- else kwargs["stream_state"]
1280
- )
1281
- stream_state = self.apply_stream_state_migrations(stream_state_migrations, stream_state)
1282
-
1283
1273
  component_type = component_definition.get("type")
1284
1274
  if component_definition.get("type") != model_type.__name__:
1285
1275
  raise ValueError(
@@ -1498,21 +1488,11 @@ class ModelToComponentFactory:
1498
1488
  component_definition: ComponentDefinition,
1499
1489
  stream_name: str,
1500
1490
  stream_namespace: Optional[str],
1491
+ stream_state: MutableMapping[str, Any],
1501
1492
  config: Config,
1502
1493
  message_repository: Optional[MessageRepository] = None,
1503
- stream_state_migrations: Optional[List[Any]] = None,
1504
1494
  **kwargs: Any,
1505
1495
  ) -> ConcurrentCursor:
1506
- # Per-partition incremental streams can dynamically create child cursors which will pass their current
1507
- # state via the stream_state keyword argument. Incremental syncs without parent streams use the
1508
- # incoming state and connector_state_manager that is initialized when the component factory is created
1509
- stream_state = (
1510
- self._connector_state_manager.get_stream_state(stream_name, stream_namespace)
1511
- if "stream_state" not in kwargs
1512
- else kwargs["stream_state"]
1513
- )
1514
- stream_state = self.apply_stream_state_migrations(stream_state_migrations, stream_state)
1515
-
1516
1496
  component_type = component_definition.get("type")
1517
1497
  if component_definition.get("type") != model_type.__name__:
1518
1498
  raise ValueError(
@@ -1587,7 +1567,6 @@ class ModelToComponentFactory:
1587
1567
  config: Config,
1588
1568
  stream_state: MutableMapping[str, Any],
1589
1569
  partition_router: PartitionRouter,
1590
- stream_state_migrations: Optional[List[Any]] = None,
1591
1570
  attempt_to_create_cursor_if_not_provided: bool = False,
1592
1571
  **kwargs: Any,
1593
1572
  ) -> ConcurrentPerPartitionCursor:
@@ -1647,11 +1626,9 @@ class ModelToComponentFactory:
1647
1626
  stream_namespace=stream_namespace,
1648
1627
  config=config,
1649
1628
  message_repository=NoopMessageRepository(),
1650
- # stream_state_migrations=stream_state_migrations, # FIXME is it expected to run migration on per partition state too?
1651
1629
  )
1652
1630
  )
1653
1631
 
1654
- stream_state = self.apply_stream_state_migrations(stream_state_migrations, stream_state)
1655
1632
  # Per-partition state doesn't make sense for GroupingPartitionRouter, so force the global state
1656
1633
  use_global_cursor = isinstance(
1657
1634
  partition_router, GroupingPartitionRouter
@@ -1974,6 +1951,7 @@ class ModelToComponentFactory:
1974
1951
  self, model: DeclarativeStreamModel, config: Config, is_parent: bool = False, **kwargs: Any
1975
1952
  ) -> AbstractStream:
1976
1953
  primary_key = model.primary_key.__root__ if model.primary_key else None
1954
+ self._migrate_state(model, config)
1977
1955
 
1978
1956
  partition_router = self._build_stream_slicer_from_partition_router(
1979
1957
  model.retriever,
@@ -2135,6 +2113,23 @@ class ModelToComponentFactory:
2135
2113
  supports_file_transfer=hasattr(model, "file_uploader") and bool(model.file_uploader),
2136
2114
  )
2137
2115
 
2116
+ def _migrate_state(self, model: DeclarativeStreamModel, config: Config) -> None:
2117
+ stream_name = model.name or ""
2118
+ stream_state = self._connector_state_manager.get_stream_state(
2119
+ stream_name=stream_name, namespace=None
2120
+ )
2121
+ if model.state_migrations:
2122
+ state_transformations = [
2123
+ self._create_component_from_model(state_migration, config, declarative_stream=model)
2124
+ for state_migration in model.state_migrations
2125
+ ]
2126
+ else:
2127
+ state_transformations = []
2128
+ stream_state = self.apply_stream_state_migrations(state_transformations, stream_state)
2129
+ self._connector_state_manager.update_state_for_stream(
2130
+ stream_name=stream_name, namespace=None, value=stream_state
2131
+ )
2132
+
2138
2133
  def _is_stop_condition_on_cursor(self, model: DeclarativeStreamModel) -> bool:
2139
2134
  return bool(
2140
2135
  model.incremental_sync
@@ -2206,17 +2201,7 @@ class ModelToComponentFactory:
2206
2201
  config: Config,
2207
2202
  ) -> Cursor:
2208
2203
  stream_name = model.name or ""
2209
- stream_state = self._connector_state_manager.get_stream_state(
2210
- stream_name=stream_name, namespace=None
2211
- )
2212
-
2213
- if model.state_migrations:
2214
- state_transformations = [
2215
- self._create_component_from_model(state_migration, config, declarative_stream=model)
2216
- for state_migration in model.state_migrations
2217
- ]
2218
- else:
2219
- state_transformations = []
2204
+ stream_state = self._connector_state_manager.get_stream_state(stream_name, None)
2220
2205
 
2221
2206
  if (
2222
2207
  model.incremental_sync
@@ -2228,10 +2213,9 @@ class ModelToComponentFactory:
2228
2213
  model_type=DatetimeBasedCursorModel,
2229
2214
  component_definition=model.incremental_sync.__dict__,
2230
2215
  stream_name=stream_name,
2216
+ stream_state=stream_state,
2231
2217
  stream_namespace=None,
2232
2218
  config=config or {},
2233
- stream_state=stream_state,
2234
- stream_state_migrations=state_transformations,
2235
2219
  partition_router=stream_slicer,
2236
2220
  attempt_to_create_cursor_if_not_provided=True, # FIXME can we remove that now?
2237
2221
  )
@@ -2242,8 +2226,8 @@ class ModelToComponentFactory:
2242
2226
  component_definition=model.incremental_sync.__dict__,
2243
2227
  stream_name=stream_name,
2244
2228
  stream_namespace=None,
2229
+ stream_state=stream_state,
2245
2230
  config=config or {},
2246
- stream_state_migrations=state_transformations,
2247
2231
  )
2248
2232
  elif type(model.incremental_sync) == DatetimeBasedCursorModel:
2249
2233
  return self.create_concurrent_cursor_from_datetime_based_cursor( # type: ignore # This is a known issue that we are creating and returning a ConcurrentCursor which does not technically implement the (low-code) StreamSlicer. However, (low-code) StreamSlicer and ConcurrentCursor both implement StreamSlicer.stream_slices() which is the primary method needed for checkpointing
@@ -2251,8 +2235,8 @@ class ModelToComponentFactory:
2251
2235
  component_definition=model.incremental_sync.__dict__,
2252
2236
  stream_name=stream_name,
2253
2237
  stream_namespace=None,
2238
+ stream_state=stream_state,
2254
2239
  config=config or {},
2255
- stream_state_migrations=state_transformations,
2256
2240
  attempt_to_create_cursor_if_not_provided=True,
2257
2241
  )
2258
2242
  else:
@@ -560,6 +560,15 @@ class HttpClient:
560
560
  data=data,
561
561
  )
562
562
 
563
+ env_settings = self._session.merge_environment_settings(
564
+ url=request.url,
565
+ proxies=request_kwargs.get("proxies"),
566
+ stream=request_kwargs.get("stream"),
567
+ verify=request_kwargs.get("verify"),
568
+ cert=request_kwargs.get("cert"),
569
+ )
570
+ request_kwargs = {**request_kwargs, **env_settings}
571
+
563
572
  response: requests.Response = self._send_with_retry(
564
573
  request=request,
565
574
  request_kwargs=request_kwargs,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: airbyte-cdk
3
- Version: 7.1.0
3
+ Version: 7.1.1
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  Home-page: https://airbyte.com
6
6
  License: MIT
@@ -172,7 +172,7 @@ airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=wnRUP0Xeru9R
172
172
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=la9Ulpc0lQewiBLKJ0FpsWxyU5XISv-ulmFRHJLJ1Pc,11292
173
173
  airbyte_cdk/sources/declarative/parsers/manifest_normalizer.py,sha256=EtKjS9c94yNp3AwQC8KUCQaAYW5T3zvFYxoWYjc_buI,19729
174
174
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=pJmg78vqE5VfUrF_KJnWjucQ4k9IWFULeAxHCowrHXE,6806
175
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=X8qIjanJCog3GflyEoZ-5ECID-xqcfFQgW3E6AzyFNU,184572
175
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=HetH_V7m96aoeuat55UVKcWQhHLNWYKicr1zqH49mIY,183379
176
176
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=TBC9AkGaUqHm2IKHMPN6punBIcY5tWGULowcLoAVkfw,1109
177
177
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=VelO7zKqKtzMJ35jyFeg0ypJLQC0plqqIBNXoBW1G2E,3001
178
178
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=ocm4hZ4k-tEGs5HLrtI8ecWSK0hGqNH0Rvz2byx_HZk,6927
@@ -382,7 +382,7 @@ airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py,sha
382
382
  airbyte_cdk/sources/streams/http/error_handlers/response_models.py,sha256=xGIVELBFY0TmH9aUq1ikoqJz8oHLr6di2JLvKWVEO-s,2236
383
383
  airbyte_cdk/sources/streams/http/exceptions.py,sha256=TTUpWq_qLPtdvXqYPpMhtYbFVQ7dGtajDVfjb6KQ8z8,2099
384
384
  airbyte_cdk/sources/streams/http/http.py,sha256=0uariNq8OFnlX7iqOHwBhecxA-Hfd5hSY8_XCEgn3jI,28499
385
- airbyte_cdk/sources/streams/http/http_client.py,sha256=rFkMWQUzgr4C8ulqOJ5tn9JfOEwbPndC6P_UIF31Kz8,25079
385
+ airbyte_cdk/sources/streams/http/http_client.py,sha256=Ys-9qCA-jFu1oQNbehCwb3K2GaJcTJp1gtoa1qujK1M,25438
386
386
  airbyte_cdk/sources/streams/http/rate_limiting.py,sha256=IwdjrHKUnU97XO4qONgYRv4YYW51xQ8SJm4WLafXDB8,6351
387
387
  airbyte_cdk/sources/streams/http/requests_native_auth/__init__.py,sha256=RN0D3nOX1xLgwEwKWu6pkGy3XqBFzKSNZ8Lf6umU2eY,413
388
388
  airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py,sha256=aWrBmJ8AhUtvtHhHq5JGVZFXjDa7jG8DZePG4gEs9VY,19800
@@ -457,9 +457,9 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EDxgROHDbfG-QKQb59m7h_7crN1tRiawdf5uU7G
457
457
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=9YDJmnIGFsT51CVQf2tSSvTapGimITjEFGbUTSZAGTI,963
458
458
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
459
459
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
460
- airbyte_cdk-7.1.0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
461
- airbyte_cdk-7.1.0.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
462
- airbyte_cdk-7.1.0.dist-info/METADATA,sha256=XxxRO3gjQdumZhkyuvOfchDtzLQFNDHHl3OH5oKw1ho,6798
463
- airbyte_cdk-7.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
464
- airbyte_cdk-7.1.0.dist-info/entry_points.txt,sha256=eLZ2UYvJZGm1s07Pplcs--1Gim60YhZWTb53j_dghwU,195
465
- airbyte_cdk-7.1.0.dist-info/RECORD,,
460
+ airbyte_cdk-7.1.1.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
461
+ airbyte_cdk-7.1.1.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
462
+ airbyte_cdk-7.1.1.dist-info/METADATA,sha256=FxrlxkaByiz849DzrEFOO9EhoNR3jgKBc2E56cQUQ68,6798
463
+ airbyte_cdk-7.1.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
464
+ airbyte_cdk-7.1.1.dist-info/entry_points.txt,sha256=eLZ2UYvJZGm1s07Pplcs--1Gim60YhZWTb53j_dghwU,195
465
+ airbyte_cdk-7.1.1.dist-info/RECORD,,