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

✨Source Notion: add new stream comments #30324

Merged
merged 33 commits into from Oct 9, 2023

Conversation

ChristoGrab
Copy link
Contributor

@ChristoGrab ChristoGrab commented Sep 11, 2023

What

Added stream for the Comments endpoint in Notion source connector.

How

  • Each stream slice returns a parent id for use in query params (following the pattern of Blocks stream).
  • To get incremental sync working properly, I used the parent page's last_edited_time as the cursor, adding it to the comment object as page_last_edited_time. I chose this approach because the order of the timestamps of the comments from one page to another can't be guaranteed, ie:
Page (Slice) I - Edited Time 2
    Comment A - Edited Time 1
    Comment B - Edited Time 4

Page (Slice) II - Edited Time 3
    Comment C - Edited Time 2
    Comment D - Edited Time 3

In this scenario, if we used the comment's last_edited_time as the cursor, the value of state will be updated to 4 after querying Page I, and in the following slice none of the comments in Page II will be synced. Because the pages query is sorted by LMD, by using the page's timestamp we can ensure that older comments in a page won't be skipped. Let me know if there's a better pattern to use that addresses this issue!

Recommended reading order

  1. streams.py
  2. test_incremental_streams.py

User Impact

No breaking changes

@octavia-squidington-iii octavia-squidington-iii added area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/source/notion labels Sep 11, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Sep 11, 2023

Before Merging a Connector Pull Request

Wow! 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:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan.
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • You've updated the connector's metadata.yaml file any other relevant changes, including a breakingChanges entry for major version bumps. See metadata.yaml docs
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • Migration guide updated in docs/integrations/<source or destination>/<name>-migrations.md with an entry for the new version, if the version is a breaking change. See migration guide example
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

@ChristoGrab ChristoGrab marked this pull request as ready for review September 12, 2023 14:05
@github-actions
Copy link
Contributor

source-notion test report (commit b860a31c4e) - ❌

⏲️ Total pipeline duration: 02mn27s

Step Result
Connector package install
Build source-notion docker image for platform linux/x86_64
Unit tests
Acceptance tests
Code format checks
Validate airbyte-integrations/connectors/source-notion/metadata.yaml
Connector version semver check
Connector version increment check
QA checks

🔗 View the logs here

☁️ 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-notion test

@github-actions
Copy link
Contributor

source-notion test report (commit ab631406ac) - ❌

⏲️ Total pipeline duration: 02mn50s

Step Result
Connector package install
Build source-notion docker image for platform linux/x86_64
Unit tests
Acceptance tests
Code format checks
Validate airbyte-integrations/connectors/source-notion/metadata.yaml
Connector version semver check
Connector version increment check
QA checks

🔗 View the logs here

☁️ 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-notion test

return f"comments"

def request_params(self, next_page_token: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, **kwargs) -> MutableMapping[str, Any]:
block_id = stream_slice.get("block_id", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a valid situation where block_id wouldn't be set? or should this throw an error if it can't find block ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, there's no valid reason that I can think of that block_id wouldn't be properly set, since every parent record's id is fetched directly from the API. I can remove the default argument (it will never trigger and after testing it would have just resulted in a 400 error anyway).


# Gather parent stream records in full
parent_records = self.parent.read_records(
sync_mode=SyncMode.full_refresh, cursor_field=self.parent.cursor_field, stream_state=stream_state
Copy link
Contributor

Choose a reason for hiding this comment

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

if we're syncing full refresh is there a reason to pass 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.

Nope, that's my bad! I'll remove the argument

@ChristoGrab ChristoGrab marked this pull request as draft September 13, 2023 18:32
@ChristoGrab ChristoGrab marked this pull request as ready for review September 13, 2023 21:29
@github-actions
Copy link
Contributor

source-notion test report (commit bedd64ef84) - ❌

⏲️ Total pipeline duration: 03mn14s

Step Result
Connector package install
Build source-notion docker image for platform linux/x86_64
Unit tests
Acceptance tests
Code format checks
Validate airbyte-integrations/connectors/source-notion/metadata.yaml
Connector version semver check
Connector version increment check
QA checks

🔗 View the logs here

☁️ 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-notion test

@ChristoGrab ChristoGrab marked this pull request as draft September 14, 2023 00:41
@vercel
Copy link

vercel bot commented Sep 22, 2023

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 Oct 9, 2023 3:09pm

@ChristoGrab ChristoGrab marked this pull request as ready for review October 9, 2023 14:58
@airbyte-oss-build-runner
Copy link
Collaborator

source-notion test report (commit cfff846f67) - ❌

⏲️ Total pipeline duration: 05mn30s

Step Result
Connector package install
Build source-notion docker image for platform(s) linux/x86_64
Unit tests
Acceptance tests
Code format checks
Validate metadata for source-notion
Connector version semver check
Connector version increment check
QA checks

🔗 View the logs here

☁️ 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-notion test

@airbyte-oss-build-runner
Copy link
Collaborator

source-notion test report (commit 3c9752af08) - ✅

⏲️ Total pipeline duration: 04mn40s

Step Result
Connector package install
Build source-notion docker image for platform(s) linux/x86_64
Unit tests
Acceptance tests
Code format checks
Validate metadata for source-notion
Connector version semver check
Connector version increment check
QA checks

🔗 View the logs here

☁️ 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-notion test

@ChristoGrab ChristoGrab merged commit 3b0269f into master Oct 9, 2023
24 checks passed
@ChristoGrab ChristoGrab deleted the christo/notion-add-comment-stream branch October 9, 2023 15:40
edgao pushed a commit that referenced this pull request Oct 11, 2023
Co-authored-by: ChristoGrab <ChristoGrab@users.noreply.github.com>
ariesgun pushed a commit to ariesgun/airbyte that referenced this pull request Oct 20, 2023
Co-authored-by: ChristoGrab <ChristoGrab@users.noreply.github.com>
ariesgun pushed a commit to ariesgun/airbyte that referenced this pull request Oct 23, 2023
Co-authored-by: ChristoGrab <ChristoGrab@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/destination/pinecone connectors/source/notion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants