-
Notifications
You must be signed in to change notification settings - Fork 40
feat(low-code cdk): add StateDelegatingStream #318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Serhii Lazebnyi (lazebnyi)
merged 67 commits into
main
from
lazebnyi/add-state-delegating-retriever
Mar 13, 2025
Merged
Changes from 8 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
ad36c6e
Add PoC for state delegating retriever
lazebnyi 1f01589
Auto-fix lint and format issues
a0e5d92
Merge branch 'main' into lazebnyi/add-state-delegating-retriever
lazebnyi 3181ac2
Update annotations
lazebnyi 5593d24
Merge master
lazebnyi f85a68e
Auto-fix lint and format issues
ff57a28
Update annotations for __getattr__
lazebnyi e46a88a
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi 1e71e63
Fix mypy
lazebnyi 9706535
Add incremental_sync validation
lazebnyi 63e9951
Move async retriever validation to quit faster
lazebnyi 387cf09
Refactor stream slicer merge method
lazebnyi b78cc6e
Fix errors messages
lazebnyi 53b2980
Merge branch 'main' into lazebnyi/add-state-delegating-retriever
lazebnyi 14138ed
Auto-fix lint and format issues
bb3b176
Refactor _merge_stream_slicers
lazebnyi 66001f1
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi 1a4b044
Auto-fix lint and format issues
8cbb9b2
Update retriever validation
lazebnyi 407766d
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi 1c38282
Auto-fix lint and format issues
88d5adb
Rollback _merge_stream_slicers
lazebnyi d3a83a4
Merge master to branch
lazebnyi 666c4fa
Auto-fix lint and format issues
8c1907a
Add ignore_first_request_options_provider and fix retriever in StateD…
lazebnyi 8417712
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi a05c391
Auto-fix lint and format issues
f0159de
Merge branch 'main' into lazebnyi/add-state-delegating-retriever
lazebnyi d7b0d25
Merge branch 'main' into lazebnyi/add-state-delegating-retriever
lazebnyi 0cd7471
Fix mypy
lazebnyi 8e7b2a3
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi 9af489d
Update StateDelegatingRetriever
lazebnyi 06cccc5
Auto-fix lint and format issues
b218f3a
Update unit test for StateDelegatingRetriever
lazebnyi b35e1e9
Merge master to branch
lazebnyi d29bd30
Auto-fix lint and format issues
bf5c241
Fix mypy
lazebnyi c70913d
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi 6fb23f6
Auto-fix lint and format issues
43a56ed
Merge branch 'main' into lazebnyi/add-state-delegating-retriever
lazebnyi 3481894
Rollback poetry.lock
lazebnyi 35a83cd
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi 19d1b22
Fix unit test
lazebnyi 4ef852e
Merge branch 'main' into lazebnyi/add-state-delegating-retriever
lazebnyi 11382f9
Add full_refresh_ignore_min_max_datetime flag
lazebnyi 4862ec1
Auto-fix lint and format issues
3f92617
Move to a two-retriever instances approach
lazebnyi 9eccc14
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi 571ffa9
Auto-fix lint and format issues
63b156e
Fix mypy
lazebnyi 5bf46a7
Merge branch 'lazebnyi/add-state-delegating-retriever' of github.com:…
lazebnyi b0d5689
Update cocurrent source
lazebnyi 204726a
Add StateDelegatingStream to schema
lazebnyi c89bc24
Add component to constructor
lazebnyi cc759dc
Add model
lazebnyi 35f359d
Update parents resolving
lazebnyi 6632d29
Update stream test
lazebnyi d2f352a
Remove state delegation retriver implementation
lazebnyi 2846522
Remove state delegation retriver import
lazebnyi 02030b5
Auto-fix lint and format issues
69bc211
Fix mypy
lazebnyi c83dce6
Fix mypy
lazebnyi 52ba2ec
Update comment to pass mypy check
lazebnyi 8465c56
Auto-fix lint and format issues
9e6134d
Remove copy import
lazebnyi 8f2554e
Split unit test to two
lazebnyi d8222f3
Update child_stat to has_parent_state
lazebnyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
airbyte_cdk/sources/declarative/retrievers/state_delegating_retriever.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # | ||
| # Copyright (c) 2025 Airbyte, Inc., all rights reserved. | ||
| # | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import ( | ||
| Any, | ||
| MutableMapping, | ||
| ) | ||
|
|
||
| from typing_extensions import deprecated | ||
|
|
||
| from airbyte_cdk.sources.declarative.incremental.declarative_cursor import DeclarativeCursor | ||
| from airbyte_cdk.sources.declarative.retrievers.retriever import Retriever | ||
| from airbyte_cdk.sources.source import ExperimentalClassWarning | ||
|
|
||
|
|
||
| @deprecated( | ||
| "This class is experimental. Use at your own risk.", | ||
| category=ExperimentalClassWarning, | ||
| ) | ||
| @dataclass | ||
| class StateDelegatingRetriever: | ||
| full_data_retriever: Retriever | ||
| incremental_data_retriever: Retriever | ||
| cursor: DeclarativeCursor | ||
|
|
||
| def __getattr__(self, name: str) -> Any: | ||
| # Avoid delegation for these internal names. | ||
| if name in { | ||
| "full_data_retriever", | ||
| "incremental_data_retriever", | ||
| "cursor", | ||
| "retriever", | ||
| "state", | ||
| }: | ||
| return object.__getattribute__(self, name) | ||
| # Delegate everything else to the active retriever. | ||
| return getattr(self.retriever, name) | ||
|
|
||
| def __setattr__(self, name: str, value: Any) -> None: | ||
| # For the internal attributes, set them directly on self. | ||
| if name in {"full_data_retriever", "incremental_data_retriever", "cursor", "state"}: | ||
| super().__setattr__(name, value) | ||
| else: | ||
| # Delegate setting attributes to the underlying retriever. | ||
| setattr(self.retriever, name, value) | ||
|
|
||
| @property | ||
| def retriever(self) -> Retriever: | ||
| return ( | ||
| self.incremental_data_retriever | ||
| if self.cursor.get_stream_state() | ||
| else self.full_data_retriever | ||
| ) | ||
|
|
||
| @property | ||
| def state(self) -> MutableMapping[str, Any]: | ||
| return self.cursor.get_stream_state() if self.cursor else {} | ||
lazebnyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @state.setter | ||
| def state(self, value: MutableMapping[str, Any]) -> None: | ||
| """State setter, accept state serialized by state getter.""" | ||
| if self.cursor: | ||
| self.cursor.set_initial_state(value) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.