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

TDL-6148: Catch and retry Attribute error and TDL-13267: Fix AdCreative requests that are not retrying #171

Merged
merged 16 commits into from
Nov 23, 2021

Conversation

savan-chovatiya
Copy link
Contributor

@savan-chovatiya savan-chovatiya commented Oct 11, 2021

Description of change

TDL-6148: catch and retry 'AttributeError: 'str' object has no attribute 'get''

  • Added AttributeError in retry_pattern decorator for all the sync related calls.
  • Also, added AttributeError into should_retry_api_error for catching.

TDL-13267: AdCreative requests that are not retrying

  • Added retry_pattern decorator on the sync_batches() function of AdCreatives with FacebookRequestError also.

Manual QA steps

  • Added unit test case for verifying retries on the above exceptions

Risks

Rollback steps

  • revert this branch

@savan-chovatiya savan-chovatiya marked this pull request as draft October 11, 2021 11:51
@savan-chovatiya savan-chovatiya changed the title TDL-6148: Catch and retry Attribute error TDL-6148: Catch and retry Attribute error and TDL-13267: Fix AdCreative requests that are not retrying Oct 12, 2021
@savan-chovatiya savan-chovatiya marked this pull request as ready for review November 12, 2021 08:44
@@ -153,6 +153,8 @@ def should_retry_api_error(exception):
return True
elif isinstance(exception, TypeError) and str(exception) == "string indices must be integers":
return True
elif isinstance(exception, AttributeError):

Choose a reason for hiding this comment

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

We can add it in the or of if isinstance(exception, FacebookBadObjectError), instead of adding a new elif.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updates as per suggestion.

@@ -0,0 +1,154 @@
import unittest

Choose a reason for hiding this comment

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

@savan-chovatiya What is the difference between the test cases written in this file and test_attribute_error_retry.py file.
In the above file as well, you are checking that call_count should be 5 times. What else you are checking in test_sync_batches_retry file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was no backoff on the sync_batches function so I added and also include the FacebookRequestError error with AttributeError error so those tests are under test_sync_batches_retry. While other test cases for AttributeError are under 'test_attribute_error_retry.py'

with self.assertRaises(AttributeError):
ad_creative_object.sync_batches([])

# verify calls inside sync_batches are called 5 times as max 5 reties provided for function

Choose a reason for hiding this comment

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

Typo: It should be 'retries'

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 the typo.

@karanpanchal-crest
Copy link

@savan-chovatiya Please add comments to which code change corresponds to which JIRA

@@ -241,6 +241,7 @@ class AdCreative(Stream):
doc: https://developers.facebook.com/docs/marketing-api/reference/adgroup/adcreatives/
'''

@retry_pattern(backoff.expo, (FacebookRequestError, AttributeError), max_tries=5, factor=5)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is for TDL-13267: AdCreative requests that are not retrying on AttributeError

Copy link
Contributor

@KrisPersonal KrisPersonal left a comment

Choose a reason for hiding this comment

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

These test cases needs to be reviewed by Kyle speer. Please assign this PR to him

Copy link
Contributor

@KrisPersonal KrisPersonal left a comment

Choose a reason for hiding this comment

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

Add Change comments in the code

@savan-chovatiya
Copy link
Contributor Author

Add Change comments in the code

Added comments for changes in code.

Copy link
Contributor

@kspeer825 kspeer825 left a comment

Choose a reason for hiding this comment

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

Left a suggestion

# verify get_ad_creatives() is called 5 times as max 5 reties provided for function
self.assertEquals(mocked_account.get_ad_creatives.call_count, 5)

def test__call_get_ads(self, mocked_sleep):
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
def test__call_get_ads(self, mocked_sleep):
def test_call_get_ads(self, mocked_sleep):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated test name as per suggestion.

savan-chovatiya and others added 3 commits November 18, 2021 19:18
…r replication key field `date_start` (#172)

* added format as date-time in schema file

* added code coverage

* added check for date format in the bookmark test

* added the check for first sync messages

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>
…streams and TDL-9872: replication keys are not specified as expected in discoverable metadata (#167)

* added valid replication keys in catalog

* modified the code

* TDL-9809: Added replication keys in metadata

* adde code coverage

* Resolved review comments

Co-authored-by: harshpatel4_crest <harsh.patel4@crestdatasys.com>
Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>
savan-chovatiya and others added 3 commits November 19, 2021 14:00
#168)

* TDL-7455: Added archived data integration test

* TDL-7455: Updated integration test

* added code coverage

* Resolved review comment

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>
Base automatically changed from crest-master to master November 19, 2021 16:19
@KrisPersonal KrisPersonal merged commit 427232f into master Nov 23, 2021
@KrisPersonal KrisPersonal deleted the TDL-6148-catch-and-retry-attribute-error branch November 23, 2021 05:24
jesuejunior pushed a commit to sixcodes/tap-facebook that referenced this pull request Mar 17, 2023
…ve requests that are not retrying (singer-io#171)

* TDL-6148: Added retry for Attribute error of sync batches

* TDL-6148: Removed unused imports from unit tests

* TDL-13267: Added retry for 500 error of AdCreatives

* TDL-6148: Add AttributeError backoff for all sync functions

* added code coverage

* Resolved review comment

* Resolved review comments

* Added code comments

* Resolved review comment

* TDL-9728: Stream `ads_insights_age_gender` has unexpected datatype for replication key field `date_start` (singer-io#172)

* added format as date-time in schema file

* added code coverage

* added check for date format in the bookmark test

* added the check for first sync messages

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

* TDL-9809: `forced-replication-method` missing from metadata for some streams and TDL-9872: replication keys are not specified as expected in discoverable metadata	 (singer-io#167)

* added valid replication keys in catalog

* modified the code

* TDL-9809: Added replication keys in metadata

* adde code coverage

* Resolved review comments

Co-authored-by: harshpatel4_crest <harsh.patel4@crestdatasys.com>
Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

* TDL-7455: Add tap-tester test to verify replication of deleted records	 (singer-io#168)

* TDL-7455: Added archived data integration test

* TDL-7455: Updated integration test

* added code coverage

* Resolved review comment

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>
Co-authored-by: Harsh <80324346+harshpatel4crest@users.noreply.github.com>
Co-authored-by: harshpatel4_crest <harsh.patel4@crestdatasys.com>
Co-authored-by: KrisPersonal <66801357+KrisPersonal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants