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 Klaviyo: improve performance and make Global Exclusions stream incremental #8592

Merged
merged 13 commits into from
Dec 13, 2021

Conversation

keu
Copy link
Contributor

@keu keu commented Dec 7, 2021

What

closes #8002
Two biggest/slowest streams are:

  • Events (incrmental)
  • GlobalExclusions (full refresh)

This PR focused mainly on improving the performance of GlobalExclusion stream.

How

  • make it semi-incremental by introducing a reverse incremental stream
  • increase page_size from 100 to 5k
  • set cursor_field
  • remove validation of the records by pydantic models

Bonus

enable Metrics stream

Recommended reading order

  1. x.java
  2. y.python

🚨 User Impact 🚨

Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.

Pre-merge Checklist

Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

+ make it semi-incremental by introducing reverse incremental stream
+ increase page_size from 100 to 5k
+ set cursor_field
+ remove validation of the records by pydantic models
@github-actions github-actions bot added the area/connectors Connector related issues label Dec 7, 2021
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@keu keu temporarily deployed to more-secrets December 7, 2021 15:57 Inactive
@keu keu temporarily deployed to more-secrets December 8, 2021 00:22 Inactive
@keu keu temporarily deployed to more-secrets December 9, 2021 14:40 Inactive
@keu keu changed the title Source Klaviyo: improve performance of global_exclusion stream 🎉 Source Klaviyo: improve performance and make Global Exclusions stream incremental Dec 9, 2021
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Dec 10, 2021
@keu keu temporarily deployed to more-secrets December 10, 2021 00:24 Inactive
@keu keu temporarily deployed to more-secrets December 10, 2021 00:59 Inactive
@keu keu temporarily deployed to more-secrets December 10, 2021 01:20 Inactive
@keu
Copy link
Contributor Author

keu commented Dec 10, 2021

/test connector=connectors/source-klaviyo

🕑 connectors/source-klaviyo https://github.com/airbytehq/airbyte/actions/runs/1561495287
✅ connectors/source-klaviyo https://github.com/airbytehq/airbyte/actions/runs/1561495287
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        76      8    89%
	 source_acceptance_test/conftest.py                     109    109     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              235     95    60%
	 source_acceptance_test/tests/test_full_refresh.py       38     27    29%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  54     24    56%
	 source_acceptance_test/utils/compare.py                 62     25    60%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py     115     14    88%
	 ------------------------------------------------------------------------
	 TOTAL                                                  946    442    53%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                         Stmts   Miss  Cover
	   self._warn("No data was collected.", slug="no-data-collected")
	 ------------------------------------------------
	 source_klaviyo/__init__.py       2      2     0%
	 source_klaviyo/schemas.py       91     91     0%
	 source_klaviyo/source.py        28     28     0%
	 source_klaviyo/streams.py      117    117     0%
	 ------------------------------------------------
	 TOTAL                          238    238     0%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                         Stmts   Miss  Cover
	 ------------------------------------------------
	 source_klaviyo/__init__.py       2      0   100%
	 source_klaviyo/schemas.py       91     26    71%
	 source_klaviyo/source.py        28     12    57%
	 source_klaviyo/streams.py      117     10    91%
	 ------------------------------------------------
	 TOTAL                          238     48    80%

@jrhizor jrhizor temporarily deployed to more-secrets December 10, 2021 01:32 Inactive
@keu keu self-assigned this Dec 10, 2021
@keu keu requested a review from sherifnada December 10, 2021 16:11
Copy link
Member

@marcosmarxm marcosmarxm left a comment

Choose a reason for hiding this comment

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

LGTM please enable Metrics streams.

@@ -58,7 +58,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Type[Stream]]:
return [
Campaigns(api_key=config.api_key),
Events(api_key=config.api_key, start_date=config.start_date),
GlobalExclusions(api_key=config.api_key),
GlobalExclusions(api_key=config.api_key, start_date=config.start_date),
Lists(api_key=config.api_key),
Copy link
Member

Choose a reason for hiding this comment

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

@keu please enable Metrics stream? See PR #8673 I'll close in favor of yours.

Copy link
Contributor Author

@keu keu Dec 12, 2021

Choose a reason for hiding this comment

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

@marcosmarxm done, I left configured_catalog.json unchanged because SAT is not using it anymore

@@ -29,6 +30,36 @@ def schema_extra(schema: MutableMapping[str, Any], model) -> None:
ref = prop.pop("$ref")
prop["oneOf"] = [{"type": "null"}, {"$ref": ref}]

@classmethod
def _expand_refs(cls, schema: Any, ref_resolver: Optional[RefResolver] = None) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Awesome job @keu Solve the problem with CI failures!

@keu keu temporarily deployed to more-secrets December 12, 2021 20:08 Inactive
Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

👍🏼

@keu
Copy link
Contributor Author

keu commented Dec 13, 2021

/publish connector=connectors/source-klaviyo

🕑 connectors/source-klaviyo https://github.com/airbytehq/airbyte/actions/runs/1575116869
✅ connectors/source-klaviyo https://github.com/airbytehq/airbyte/actions/runs/1575116869

@jrhizor jrhizor temporarily deployed to more-secrets December 13, 2021 22:08 Inactive
@keu keu temporarily deployed to more-secrets December 13, 2021 23:30 Inactive
Copy link
Member

@marcosmarxm marcosmarxm left a comment

Choose a reason for hiding this comment

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

awesome @eugene-kulak

@keu keu merged commit 678b532 into master Dec 13, 2021
@keu keu deleted the keu/8002-klaviyo-performance branch December 13, 2021 23:47
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
…am incremental (airbytehq#8592)

* improve performance of global_exclusion stream
+ make it semi-incremental by introducing a reverse incremental stream
+ increase page_size from 100 to 5k
+ set cursor_field
+ remove validation of the records by pydantic models
* enable Metrics stream

Co-authored-by: Eugene Kulak <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Find ways to accelerate Klaviyo connector
8 participants