-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Connector builder: read input state if it exists #37495
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
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b90b34a
Set state of slices
girarda 4e0268e
mypy
girarda 9cfc434
remove unused import
girarda 7a2ee53
update
girarda 543e233
reset to master
girarda c57b31b
Merge branch 'alex/builder_state' into alex/builder_incremental
girarda 4c17b72
Merge branch 'master' into alex/builder_incremental
girarda c5ad904
update
girarda bf825d2
mypy and format
girarda 188c998
Merge branch 'master' into alex/builder_incremental
girarda cd4d129
update unit tests
girarda 0e44d25
Merge branch 'alex/builder_incremental' of github.com:airbytehq/airby…
girarda c8efa13
update state to an array of messages
girarda 117ea42
Assert the state is passed around
girarda 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
AirbyteControlMessage, | ||
AirbyteLogMessage, | ||
AirbyteMessage, | ||
AirbyteStateMessage, | ||
AirbyteTraceMessage, | ||
ConfiguredAirbyteCatalog, | ||
OrchestratorType, | ||
|
@@ -75,6 +76,7 @@ def get_message_groups( | |
source: DeclarativeSource, | ||
config: Mapping[str, Any], | ||
configured_catalog: ConfiguredAirbyteCatalog, | ||
state: List[AirbyteStateMessage], | ||
record_limit: Optional[int] = None, | ||
) -> StreamRead: | ||
if record_limit is not None and not (1 <= record_limit <= self._max_record_limit): | ||
|
@@ -96,7 +98,7 @@ def get_message_groups( | |
latest_config_update: AirbyteControlMessage = None | ||
auxiliary_requests = [] | ||
for message_group in self._get_message_groups( | ||
self._read_stream(source, config, configured_catalog), | ||
self._read_stream(source, config, configured_catalog, state), | ||
schema_inferrer, | ||
datetime_format_inferrer, | ||
record_limit, | ||
|
@@ -279,12 +281,13 @@ def _close_page( | |
current_page_records.clear() | ||
|
||
def _read_stream( | ||
self, source: DeclarativeSource, config: Mapping[str, Any], configured_catalog: ConfiguredAirbyteCatalog | ||
self, source: DeclarativeSource, config: Mapping[str, Any], configured_catalog: ConfiguredAirbyteCatalog, | ||
state: List[AirbyteStateMessage] | ||
) -> Iterator[AirbyteMessage]: | ||
# the generator can raise an exception | ||
# iterate over the generated messages. if next raise an exception, catch it and yield it as an AirbyteLogMessage | ||
try: | ||
yield from AirbyteEntrypoint(source).read(source.spec(self.logger), config, configured_catalog, {}) | ||
yield from AirbyteEntrypoint(source).read(source.spec(self.logger), config, configured_catalog, state) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the input state used to be hardcoded to an empty legacy state object |
||
except Exception as e: | ||
error_message = f"{e.args[0] if len(e.args) > 0 else str(e)}" | ||
yield AirbyteTracedException.from_exception(e, message=error_message).as_airbyte_message() | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked the same question over slack, but asking here too for posterity: it seems like the connection state UI shows a list of AirbyteStreamState objects, whereas this method takes in a list of AirbyteStateMessages.
Which one is right? Ideally these would be consistent so anyone could copy the state from the connection UI and paste it into the builder's state input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed on slack:
AirbyteStateMessage
s in the builder because they contain more information