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 Monday: Add incremental sync for Items stream #27944

Merged

Conversation

tolik0
Copy link
Contributor

@tolik0 tolik0 commented Jul 4, 2023

What

Implements incremental sync for Items stream. Adds new stream: Activity logs.
#20950

How

This pull request implements incremental synchronization for the Items stream by implementing the approach described in the connected issue. The implementation follows these steps:

  • Initial Sync: All items are synced initially without relying on activity logs.
  • Subsequent Sync: The process involves fetching updates since a specified date from the Activity logs stream. The modified item IDs are extracted from the activity logs. Based on these extracted IDs, the corresponding items are selectively synced to ensure their data is up to date.

Following this process, the pull request achieves incremental synchronization by selectively updating only the modified items, as indicated by the activity logs.

Recommended reading order

  1. source-monday/manifest.yaml
  2. source-monday/extractor.py
  3. source-monday/components.py
  4. source-monday/graphql_requester.py

@tolik0 tolik0 linked an issue Jul 4, 2023 that may be closed by this pull request
@octavia-squidington-iii octavia-squidington-iii added area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/source/monday labels Jul 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 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 and you've followed all steps in the Breaking Changes Checklist
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • 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
  • The connector tests are passing in CI
  • You've updated the connector's metadata.yaml file (new!)
  • 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.

@tolik0 tolik0 requested a review from bazarnov July 4, 2023 12:34
@tolik0 tolik0 self-assigned this Jul 5, 2023
Copy link
Collaborator

@bazarnov bazarnov left a comment

Choose a reason for hiding this comment

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

small changes are requested, also please run the CAT locally before making this PR "ready for review"

thanks

@tolik0 tolik0 force-pushed the tolik0/source-monday/20950-source-mondaycom-incremental-sync branch from c267655 to 0c95f12 Compare July 5, 2023 13:38
@tolik0 tolik0 changed the title Source Monday: Add incremental sync ✨ Source Monday: Add incremental sync for Items stream Jul 7, 2023
@tolik0 tolik0 marked this pull request as ready for review July 7, 2023 16:09
@tolik0 tolik0 requested a review from bazarnov July 7, 2023 16:10
@octavia-squidington-iii
Copy link
Collaborator

source-monday test report (commit abde7c925e) - ❌

⏲️ Total pipeline duration: 01mn31s

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

🔗 View the logs here

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-monday test

@octavia-squidington-iii
Copy link
Collaborator

source-monday test report (commit 7b7c9abcf5) - ❌

⏲️ Total pipeline duration: 19mn38s

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

🔗 View the logs here

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-monday test

@octavia-squidington-iii
Copy link
Collaborator

source-monday test report (commit 16c5918f8b) - ✅

⏲️ Total pipeline duration: 17mn48s

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

🔗 View the logs here

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-monday test

# this change applies for all configs bellow.
# changed type of id for assets in items and updates
# change deprecated owner to owners in boards
# All changes described in corresponding pr
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add link to PR and delete
# changed type of id for assets in items and updates
# change deprecated owner to owners in boards

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

Choose a reason for hiding this comment

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

please add link to PR instead number

Comment on lines 184 to 197
def close_slice(self, stream_slice: StreamSlice, most_recent_record: Optional[Record]) -> None:
max_dt = self._state if self.is_greater_than_or_equal(self._state, most_recent_record) else most_recent_record

if not max_dt:
return
self._state[self.cursor_field.eval(self.config)] = max_dt[self.cursor_field.eval(self.config)]

if self.parent_stream:
if self.parent_cursor_field not in most_recent_record:
date_str = most_recent_record[self.cursor_field.eval(self.config)]
parent_cursor = int(datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S%z").timestamp())
else:
parent_cursor = most_recent_record[self.parent_cursor_field]
self._state[self.parent_stream_name] = {self.parent_cursor_field: parent_cursor}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def close_slice(self, stream_slice: StreamSlice, most_recent_record: Optional[Record]) -> None:
max_dt = self._state if self.is_greater_than_or_equal(self._state, most_recent_record) else most_recent_record
if not max_dt:
return
self._state[self.cursor_field.eval(self.config)] = max_dt[self.cursor_field.eval(self.config)]
if self.parent_stream:
if self.parent_cursor_field not in most_recent_record:
date_str = most_recent_record[self.cursor_field.eval(self.config)]
parent_cursor = int(datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S%z").timestamp())
else:
parent_cursor = most_recent_record[self.parent_cursor_field]
self._state[self.parent_stream_name] = {self.parent_cursor_field: parent_cursor}
def close_slice(self, stream_slice: StreamSlice, last_record: Optional[Record]) -> None:
max_dt = self._state if self.is_greater_than_or_equal(self._state, most_recent_record) else most_recent_record
if not max_dt:
return
cursor_field_eval = self.cursor_field.eval(self.config)
self._state[cursor_field_eval] = max_dt[cursor_field_eval]
if self.parent_stream:
date_str = most_recent_record[self.cursor_field.eval(self.config)]
default_parent_cursor = int(datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S%z").timestamp())
parent_cursor = most_recent_record.get(self.parent_cursor_field, default_parent_cursor)
self._state[self.parent_stream_name] = {self.parent_cursor_field: parent_cursor}

@tolik0 tolik0 force-pushed the tolik0/source-monday/20950-source-mondaycom-incremental-sync branch from 8402029 to 4d4abc4 Compare July 11, 2023 17:05
@octavia-squidington-iii
Copy link
Collaborator

source-monday test report (commit 1746c57a70) - ❌

⏲️ Total pipeline duration: 57.28s

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

🔗 View the logs here

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-monday test

@octavia-squidington-iii
Copy link
Collaborator

source-monday test report (commit df87dd0970) - ❌

⏲️ Total pipeline duration: 36.09s

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

🔗 View the logs here

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-monday test

@octavia-squidington-iii
Copy link
Collaborator

source-monday test report (commit 19cbfa94ca) - ✅

⏲️ Total pipeline duration: 04mn08s

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

🔗 View the logs here

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-monday test

@tolik0 tolik0 requested review from lazebnyi and bazarnov July 11, 2023 18:02
@tolik0 tolik0 requested a review from lazebnyi July 11, 2023 22:33
@octavia-squidington-iii
Copy link
Collaborator

source-monday test report (commit 4c31c40767) - ✅

⏲️ Total pipeline duration: 04mn14s

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

🔗 View the logs here

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-monday test

Copy link
Collaborator

@lazebnyi lazebnyi left a comment

Choose a reason for hiding this comment

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

LGTM! Minor change required.

@octavia-squidington-iii
Copy link
Collaborator

source-monday test report (commit 334138abe9) - ✅

⏲️ Total pipeline duration: 04mn11s

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

🔗 View the logs here

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-monday test

@tolik0 tolik0 merged commit 507ad69 into master Jul 13, 2023
22 of 23 checks passed
@tolik0 tolik0 deleted the tolik0/source-monday/20950-source-mondaycom-incremental-sync branch July 13, 2023 09:13
efimmatytsin pushed a commit to scentbird/airbyte that referenced this pull request Jul 27, 2023
…rbytehq#27944)

* Add incremental sync for the Boards and Items streams using Activity logs

---------

Co-authored-by: Oleksandr Bazarnov <oleksandr.bazarnov@globallogic.com>
Co-authored-by: Sherif A. Nada <snadalive@gmail.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/source/monday
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source Monday.com: Incremental Sync
5 participants