Repository navigation
Source s3 cursor with history adapter - #29028
Conversation
Before Merging a Connector Pull RequestWow! What a great pull request you have here! 🎉 To merge this PR, ensure the following has been done/considered for each connector added or updated:
If the checklist is complete, but the CI check is failing,
|
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| QA checks | ✅ |
| Code format checks | ❌ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ❌ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 teste462779 to
5dd8d06
Compare
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ❌ |
| QA checks | ✅ |
| Code format checks | ❌ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 test
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ❌ |
| Code format checks | ❌ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ❌ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 testebe3cd9 to
7a6a6b9
Compare
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ✅ |
| Code format checks | ❌ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 testefd77d9 to
10ce5fe
Compare
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ✅ |
| Code format checks | ❌ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 test10ce5fe to
0a23e96
Compare
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ✅ |
| Code format checks | ❌ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 test0a23e96 to
fb0cf97
Compare
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ✅ |
| Code format checks | ✅ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 test
Maxime Carbonneau-Leclerc (maxi297)
left a comment
There was a problem hiding this comment.
I feel like test coverage does not guarantee the behavior we would like. Can we test public methods instead?
| return True | ||
| else: | ||
| return False | ||
| if cursor := stream_state.get(self.cursor_field): |
There was a problem hiding this comment.
This seems like an edge case but if the cursor_field change, the state will be considered as V3. Is that ok?
There was a problem hiding this comment.
Good call-out, and I'm okay with that since it's an edge case, and we will hopefully be deprecating v3 before too long.
| ], | ||
| ) | ||
| def test_convert_dates(input_history: MutableMapping[str, Any], expected_output: MutableMapping[str, Any]) -> None: | ||
| assert Cursor._convert_legacy_history(input_history) == expected_output |
There was a problem hiding this comment.
It seems like this test does not guarantee that the public interface is working as expected i.e. set_initial_state could do something completely unexpected and we won't know with this coverage. Should we test set_initial_state instead?
There was a problem hiding this comment.
That's a good call, updated tests to use that.
There was a problem hiding this comment.
Btw this change caught a bug. Updated code in airbyte-integrations/connectors/source-s3/source_s3/v4/cursor.py if you want to take another look.
| timestamp_millis = stream_state[self.cursor_field].split("_")[0] | ||
| converted_state[self.cursor_field] = self._get_ts_from_millis_ts(timestamp_millis, "%Y-%m-%dT%H:%M:%SZ") | ||
| if "history" in stream_state: | ||
| converted_state["history"] = converted_history |
There was a problem hiding this comment.
nit: I think we can always set converted_state["history"] = converted_history. It'll just be an empty object if the stream_state doesn't have a history field
| def get_source(args: List[str]): | ||
| catalog_path = AirbyteEntrypoint.extract_catalog(args) | ||
| try: | ||
| return FileBasedSource(SourceS3StreamReader(), Config, catalog_path, cursor_cls=Cursor) |
There was a problem hiding this comment.
can you elaborate on why or what scenario we need this additional try/catch a opposed to just initializing it the way we had been doing before?
There was a problem hiding this comment.
Yes so I added this in order to make the CATs pass. When check errors, they expect the error to be output as an AirbyteMessage. But if we initialize FileBasedSource outside of the try that won't happen.
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ✅ |
| Code format checks | ✅ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 test
Alexandre Girard (girarda)
left a comment
There was a problem hiding this comment.
🚢 🚢 🚢
0127a8f to
78dcbe8
Compare
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ✅ |
| Code format checks | ✅ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ❌ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 test
Brian Lai (brianjlai)
left a comment
There was a problem hiding this comment.
just small nits, nothing major so looks good!
| if not timestamp: | ||
| return timestamp | ||
| try: | ||
| timestamp_millis = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ") |
There was a problem hiding this comment.
nit: but since this is used in mroe than one place in the file (also on line 460), can we make this a constant
There was a problem hiding this comment.
👍 done.
|
|
||
| for filename in filenames: | ||
| if filename in converted_history: | ||
| if date_obj > datetime.strptime(converted_history[filename], "%Y-%m-%dT%H:%M:%S.%fZ"): |
There was a problem hiding this comment.
same here let's use a constant since its used 3 times
There was a problem hiding this comment.
👍 done.
78dcbe8 to
c14d044
Compare
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ✅ |
| Code format checks | ✅ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 testc14d044 to
5e32482
Compare
|
| Step | Result |
|---|---|
| Validate airbyte-integrations/connectors/source-s3/metadata.yaml | ✅ |
| Connector version semver check | ✅ |
| Connector version increment check | ✅ |
| QA checks | ✅ |
| Code format checks | ✅ |
| Connector package install | ✅ |
| Build source-s3 docker image for platform linux/x86_64 | ✅ |
| Unit tests | ✅ |
| Integration tests | ✅ |
| Acceptance tests | ✅ |
☁️ View runs for commit in Dagger Cloud
Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command
airbyte-ci connectors --name=source-s3 testsource-s3 previously used the legacy DefaultFileBasedCursor via the
source-s3-specific Cursor subclass. That cursor goes through the legacy
non-concurrent file-based read path, which emits a state message per
processed file. With ~10 k files in a stream, the platform/orchestrator
buffers ~10 k state messages (each carrying the growing history dict)
waiting for the destination to ACK them; on slow destinations the
orchestrator pod OOMs, the source pod is torn down before emitting
terminal stream status, and the destination fails with
TransientErrorException("Input was fully read, but some streams did not
receive a terminal stream status message").
Move source-s3 onto FileBasedConcurrentCursor (CDK) which:
- emits state at most once per 600s during a sync (state throttle
added in airbytehq/airbyte-python-cdk#1032);
- always force-emits a final state via ensure_at_least_one_state_emitted;
- runs the read on the concurrent file-based path with up to
DEFAULT_CONCURRENCY (100) workers.
Verified locally against a customer connection with ~9 k files: state
messages dropped from 9 200 to 2, runtime from 52:46 to 4:24, stdout
volume from 4.1 GB to 922 MB, sync completes successfully with a
STREAM_STATUS COMPLETE.
The legacy source-s3 Cursor class only existed to host the v3-to-v4
state migration shipped in 2023 (#29028). 2.5 years on, all active
customers have completed the migration on their first v4 sync, so the
subclass and its tests are removed. A hypothetical customer with stale
v3 state would trigger one full re-sync, after which they'd be on v4.
Pinning to airbyte-cdk 7.19.2.post3.dev26244645194, a prerelease that
includes both the state throttle and a fallback-branch dispatch fix
for the file-based source so connectors using FileBasedConcurrentCursor
do not crash on partial-catalog reads / check / discover.
Creates a Cursor object for source S3 that adapts state message in the old format to the new format.
Depends on #29027.