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

Python CDK: fix retry attempts in case of user defined backoff time #5707

Merged
merged 3 commits into from
Aug 31, 2021

Conversation

avida
Copy link
Contributor

@avida avida commented Aug 27, 2021

What

Part of fix for #5683

How

Describe the solution

Recommended reading order

  1. x.java
  2. y.python

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
    • docs/SUMMARY.md
    • 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
  • Connector added to connector index like described here

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

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
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions
  • Connector version bumped like described here

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

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.

@github-actions github-actions bot added the CDK Connector Development Kit label Aug 27, 2021
1 to expected retries attempts.
"""
max_tries = self.max_retries
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

lets not use docstrings in the middle of the function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its not a docstring unless it occurs as the first statement in a module, function, class, or method definition. In this case its just a multi line comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

what I mean is that having novels like this in the middle of the function makes it hard to read and understand. please move it to the top.

@avida avida requested a review from keu August 27, 2021 16:01
max_tries: The maximum number of attempts to make before giving
up ...The default value of None means there is no limit to
the number of tries.
This implies that is max_tries is excplicitly set to None there is no
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This implies that is max_tries is excplicitly set to None there is no
This implies that if max_tries is excplicitly set to None there is no

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@Zirochkaa Zirochkaa left a comment

Choose a reason for hiding this comment

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

lgtm, just a few comments.
Also, please, check @keu's comments again.

Comment on lines +177 to +179
with pytest.raises(UserDefinedBackoffException):
list(stream.read_records(SyncMode.full_refresh))
if retries <= 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
with pytest.raises(UserDefinedBackoffException):
list(stream.read_records(SyncMode.full_refresh))
if retries <= 0:
with pytest.raises(UserDefinedBackoffException):
list(stream.read_records(SyncMode.full_refresh))
if retries <= 0:

Comment on lines +202 to +203
list(stream.read_records(SyncMode.full_refresh))
assert send_mock.call_count == infinite_number + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
list(stream.read_records(SyncMode.full_refresh))
assert send_mock.call_count == infinite_number + 1
list(stream.read_records(SyncMode.full_refresh))
assert send_mock.call_count == infinite_number + 1

with pytest.raises(DefaultBackoffException):
list(stream.read_records(SyncMode.full_refresh))
assert send_mock.call_count == stream.max_retries + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert send_mock.call_count == stream.max_retries + 1
assert send_mock.call_count == stream.max_retries + 1

@avida avida requested a review from sherifnada August 30, 2021 13:39
@avida avida linked an issue Aug 30, 2021 that may be closed by this pull request
@sherifnada sherifnada requested review from Phlair and removed request for sherifnada August 30, 2021 14:50
explicitly (i.e. max_retries is not None).
"""
if max_tries is not None:
max_tries = max(0, max_tries) + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

can it just be max(1, max_tries)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but max(1, max_tries + 1)

@sherifnada sherifnada removed the request for review from Phlair August 30, 2021 14:53
@avida avida merged commit eed2e10 into master Aug 31, 2021
@avida avida deleted the drezchykov/5683-CDK-fix branch August 31, 2021 06:55
@avida
Copy link
Contributor Author

avida commented Aug 31, 2021

/publish-cdk dry-run=false

Error: No ref found for: drezchykov/5683-CDK-fix

@avida avida restored the drezchykov/5683-CDK-fix branch August 31, 2021 06:58
@avida
Copy link
Contributor Author

avida commented Aug 31, 2021

/publish-cdk dry-run=false

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source Slack: hitting max retries
4 participants