Skip to content
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

Connector builder: read input state if it exists #37495

Merged
merged 14 commits into from
Apr 24, 2024
Merged

Conversation

girarda
Copy link
Contributor

@girarda girarda commented Apr 23, 2024

What

Updates the connector builder to read an optional input state and pass it to the Entrypoint's read command.

This enables the test_read endpoint to read incrementally.

Demo with the builder: https://www.loom.com/share/169c02e5b9e04723ad5b048aa616c27a

Can this PR be safely reverted and rolled back?

  • YES 💚

Copy link

vercel bot commented Apr 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:58am

@octavia-squidington-iii octavia-squidington-iii added the CDK Connector Development Kit label Apr 23, 2024
@girarda girarda changed the title Alex/builder incremental Connector builder: read input state if it exists Apr 23, 2024
) -> 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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

@girarda girarda marked this pull request as ready for review April 23, 2024 01:06
@girarda girarda requested a review from a team as a code owner April 23, 2024 01:06
Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need more info on the state inferface before approving

@@ -457,7 +459,7 @@ def test_read():
limits = TestReadLimits()
with patch("airbyte_cdk.connector_builder.message_grouper.MessageGrouper.get_message_groups", return_value=stream_read):
output_record = handle_connector_builder_request(
source, "test_read", config, ConfiguredAirbyteCatalog.parse_obj(CONFIGURED_CATALOG), limits
source, "test_read", config, ConfiguredAirbyteCatalog.parse_obj(CONFIGURED_CATALOG), _NO_STATE, limits
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test here that actually sets some state, to make sure that is handled properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



def handle_connector_builder_request(
source: ManifestDeclarativeSource,
command: str,
config: Mapping[str, Any],
catalog: Optional[ConfiguredAirbyteCatalog],
state: List[AirbyteStateMessage],
Copy link
Contributor

@lmossman lmossman Apr 23, 2024

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.

Screenshot 2024-04-23 at 2 23 21 PM

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on slack:

  • we'll use AirbyteStateMessages in the builder because they contain more information
  • we won't couple this with the platform view. We'll brainstorm novel solutions if the need to paste configs from existing connections really is a need

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally in conjunction with the builder and this works as expected, LGTM!

@girarda girarda merged commit 86ee91e into master Apr 24, 2024
35 checks passed
@girarda girarda deleted the alex/builder_incremental branch April 24, 2024 22:53
FVidalCarneiro pushed a commit to AgiData/airbyte that referenced this pull request May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants