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

Alex/limit paginator #17197

Merged
merged 17 commits into from
Sep 30, 2022
Merged

Alex/limit paginator #17197

merged 17 commits into from
Sep 30, 2022

Conversation

girarda
Copy link
Contributor

@girarda girarda commented Sep 27, 2022

What

Follow up item:

  • Update greenhouse

Recommended reading order

  1. airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py
  2. airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py
  3. airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py
  4. airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py
  5. airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py
  6. airbyte-cdk/python/airbyte_cdk/sources/declarative/parsers/class_types_registry.py

🚨 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

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? 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
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • 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
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index 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
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
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@github-actions github-actions bot added area/connectors Connector related issues area/documentation Improvements or additions to documentation CDK Connector Development Kit labels Sep 27, 2022
inject_into: request_parameter
field_name: page_size
field_name: limit
Copy link
Contributor Author

Choose a reason for hiding this comment

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


Iterating over pages of result is different from iterating over stream slices.
Stream slices have semantic value, for instance, a Datetime stream slice defines data for a specific date range. Two stream slices will have data for different date ranges.
Conversely, pages don't have semantic value. More pages simply means that more records are to be read, without specifying any meaningful difference between the records of the first and later pages.

The paginator is defined by

- `page_size`: The number of records to fetch in a single request
- `limit_option`: How to specify the page size in the outgoing HTTP request
- `page_size_option`: How to specify the page size in the outgoing HTTP request
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add complete schema definitions in a follow up PR

page_token_option (RequestOption): the request option to set the page token
pagination_strategy (PaginationStrategy): Strategy defining how to get the next page token
config (Config): connection config
url_base (Union[InterpolatedString, str]): endpoint's base url
decoder (Decoder): decoder to decode the response
"""

page_size: int
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to the strategy

@@ -16,7 +16,7 @@
author="Airbyte",
author_email="contact@airbyte.io",
packages=find_packages(),
install_requires=["airbyte-cdk", "dataclasses-jsonschema==2.15.1"],
install_requires=["airbyte-cdk==0.1.89", "dataclasses-jsonschema==2.15.1"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

freeze the version until greenhouse.yaml is updated

Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

@@ -16,7 +16,7 @@ definitions:
type: "BearerAuthenticator"
api_token: "{{ config.apikey }}"
cursor_paginator:
type: LimitPaginator
type: DefaultPaginator
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sendgrid is safe to update because it is not used in production

@@ -18,7 +18,7 @@ definitions:
type: "BearerAuthenticator"
api_token: "{{ config.auth_token }}"
paginator:
type: LimitPaginator
type: DefaultPaginator
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sentry is safe to update because it is not used in production

@girarda girarda marked this pull request as ready for review September 29, 2022 21:25
@girarda girarda requested a review from a team as a code owner September 29, 2022 21:25
Copy link
Contributor

@brianjlai brianjlai left a comment

Choose a reason for hiding this comment

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

i had a question related to why the cursor paginator needs to have a field for the page size. If anything we might want to leave it out of language til proven we needed it. But nothing to block on!

## 0.1.89

Copy link
Contributor

Choose a reason for hiding this comment

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

Were these formatting changes intended? Did the linter/formatter get changed?

inject_into: header
field_name: page_size
pagination_strategy:
type: "OffsetIncrement"
page_size: 5
page_token:
Copy link
Contributor

@brianjlai brianjlai Sep 29, 2022

Choose a reason for hiding this comment

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

should this also be renamed to page_token_option? not the changed line, but the one below it (line 54)

@@ -30,6 +31,7 @@ class CursorPaginationStrategy(PaginationStrategy, JsonSchemaMixin):
cursor_value: Union[InterpolatedString, str]
config: Config
options: InitVar[Mapping[str, Any]]
page_size: Optional[int] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the use case for page_size in a cursor paginator? We need the method to be defined to satisfy the interface, but maybe we should just return None? Also useful for making it easy to throw an error in the DefaultPaginator if the developer sets a page_size_option for a cursor paginator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

some APIs use a page size with a cursor (request 5 records per page and get the next page from the cursor)

Copy link
Contributor

Choose a reason for hiding this comment

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

ah okay, makes sense!

@@ -16,7 +16,7 @@
author="Airbyte",
author_email="contact@airbyte.io",
packages=find_packages(),
install_requires=["airbyte-cdk", "dataclasses-jsonschema==2.15.1"],
install_requires=["airbyte-cdk==0.1.89", "dataclasses-jsonschema==2.15.1"],
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

@girarda
Copy link
Contributor Author

girarda commented Sep 30, 2022

/publish-cdk dry-run=true

🕑 https://github.com/airbytehq/airbyte/actions/runs/3155596188
https://github.com/airbytehq/airbyte/actions/runs/3155596188

@girarda
Copy link
Contributor Author

girarda commented Sep 30, 2022

/publish-cdk dry-run=false

🕑 https://github.com/airbytehq/airbyte/actions/runs/3155627612
https://github.com/airbytehq/airbyte/actions/runs/3155627612

@girarda girarda merged commit d6b79b8 into master Sep 30, 2022
@girarda girarda deleted the alex/limitPaginator branch September 30, 2022 02:24
jhammarstedt pushed a commit to jhammarstedt/airbyte that referenced this pull request Oct 31, 2022
* remove page size from limit paginator

* Rename LimitPaginator to DefaultPaginator

* rename limit_options

* rename method

* cleanup

* comment

* update schema file

* Update changelog

* pin greenhouse connector

* fix doc in comment

* fix changelog

* missing -

* bump

* bump
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 CDK Connector Development Kit connectors/source/greenhouse connectors/source/sendgrid connectors/source/sentry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[low code cdk] Remove page_size from the LimitPaginator definition
4 participants