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 Amazon Seller Partner: add replication end date to config #13059

Merged

Conversation

ganpatagarwal
Copy link
Contributor

@ganpatagarwal ganpatagarwal commented May 20, 2022

What

*With a custom replication end date, users will be able to fetch data for a specified period.
*It will also help in batching the fetches while pulling report for a longer duration ,say 3 years.

How

*Most of the SP APIs support a parameter to provide end date, e.g “dataEndTime”, “LastUpdatedBefore”, etc.
*When a user provides a valid date time against End Date(replication_end_date), it would be used with the APIs.
*End Date(replication_end_date) is an optional config option with a default value of default. When default value is present, it would be treated as no end date is provided by user, and no specific end date parameter would get added to API calls.

Recommended reading order

  1. spec.json
  2. source.py
  3. streams.py

🚨 User Impact 🚨

No user impact, as End Date(replication_end_date) config is optional. Also, default value makes sure to not include any end-date parameter.

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

Tests

Unit
python -m pytest -s unit_tests
Test session starts (platform: darwin, Python 3.9.11, pytest 6.1.2, pytest-sugar 0.9.4)
cachedir: .pytest_cache
rootdir: /Users/ganpatagarwal/stoke/airbyte, configfile: pytest.ini
plugins: mock-3.7.0, sugar-0.9.4, timeout-1.4.2
collecting ...
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_reports_streams_rate_limits.py::test_reports_stream_should_retry ✓                                 1% ▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_reports_streams_rate_limits.py::test_reports_stream_send_request ✓                                 2% ▎         {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send_request(...) for 5.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: None, Response Code: 429, Response Text: )"}}
{"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: None, Response Code: 429, Response Text: ' after 1 tries. Waiting 5 seconds then retrying..."}}
{"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send_request(...) for 10.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: None, Response Code: 429, Response Text: )"}}
{"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: None, Response Code: 429, Response Text: ' after 2 tries. Waiting 10 seconds then retrying..."}}
{"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send_request(...) for 20.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: None, Response Code: 429, Response Text: )"}}
{"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: None, Response Code: 429, Response Text: ' after 3 tries. Waiting 20 seconds then retrying..."}}
{"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send_request(...) for 40.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: None, Response Code: 429, Response Text: )"}}
{"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: None, Response Code: 429, Response Text: ' after 4 tries. Waiting 40 seconds then retrying..."}}
{"type": "LOG", "log": {"level": "ERROR", "message": "Giving up _send_request(...) after 5 tries (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: None, Response Code: 429, Response Text: )"}}

 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_reports_streams_rate_limits.py::test_reports_stream_send_request_backoff_exception ✓               3% ▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_spec ✓                                                                             5% ▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_streams ✓                                                                          6% ▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_stream_with_good_iam_arn_value[arn:aws:iam::123456789098:user/some-user] ✓         7% ▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_stream_with_good_iam_arn_value[arn:aws:iam::123456789098:role/some-role] ✓         8% ▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_stream_with_bad_iam_arn_value ✓                                                    9% ▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2VIGQ35RCS4UG-input_data0-expected_data0] ✓10% █
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2VIGQ35RCS4UG-input_data1-expected_data1] ✓11% █▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2VIGQ35RCS4UG-input_data2-expected_data2] ✓12% █▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2VIGQ35RCS4UG-input_data3-expected_data3] ✓14% █▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1PA6795UKMFR9-input_data4-expected_data4] ✓15% █▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1PA6795UKMFR9-input_data5-expected_data5] ✓16% █▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1PA6795UKMFR9-input_data6-expected_data6] ✓17% █▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1PA6795UKMFR9-input_data7-expected_data7] ✓18% █▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1C3SOZRARQ6R3-input_data8-expected_data8] ✓19% █▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1C3SOZRARQ6R3-input_data9-expected_data9] ✓20% ██▏
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1C3SOZRARQ6R3-input_data10-expected_data10] ✓22% ██▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1C3SOZRARQ6R3-input_data11-expected_data11] ✓23% ██▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[ARBP9OOSHTCHU-input_data12-expected_data12] ✓24% ██▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[ARBP9OOSHTCHU-input_data13-expected_data13] ✓25% ██▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[ARBP9OOSHTCHU-input_data14-expected_data14] ✓26% ██▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[ARBP9OOSHTCHU-input_data15-expected_data15] ✓27% ██▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1RKKUPIHCS9HS-input_data16-expected_data16] ✓28% ██▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1RKKUPIHCS9HS-input_data17-expected_data17] ✓30% ██▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1RKKUPIHCS9HS-input_data18-expected_data18] ✓31% ███▏
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1RKKUPIHCS9HS-input_data19-expected_data19] ✓32% ███▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A13V1IB3VIYZZH-input_data20-expected_data20] ✓33% ███▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A13V1IB3VIYZZH-input_data21-expected_data21] ✓34% ███▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A13V1IB3VIYZZH-input_data22-expected_data22] ✓35% ███▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A13V1IB3VIYZZH-input_data23-expected_data23] ✓36% ███▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A21TJRUUN4KGV-input_data24-expected_data24] ✓38% ███▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A21TJRUUN4KGV-input_data25-expected_data25] ✓39% ███▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A21TJRUUN4KGV-input_data26-expected_data26] ✓40% ████
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A21TJRUUN4KGV-input_data27-expected_data27] ✓41% ████▏
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[APJ6JRA9NG5V4-input_data28-expected_data28] ✓42% ████▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[APJ6JRA9NG5V4-input_data29-expected_data29] ✓43% ████▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[APJ6JRA9NG5V4-input_data30-expected_data30] ✓44% ████▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[APJ6JRA9NG5V4-input_data31-expected_data31] ✓45% ████▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1805IZSGTT6HS-input_data32-expected_data32] ✓47% ████▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1805IZSGTT6HS-input_data33-expected_data33] ✓48% ████▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1805IZSGTT6HS-input_data34-expected_data34] ✓49% ████▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1805IZSGTT6HS-input_data35-expected_data35] ✓50% █████
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A17E79C6D8DWNP-input_data36-expected_data36] ✓51% █████▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A17E79C6D8DWNP-input_data37-expected_data37] ✓52% █████▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A17E79C6D8DWNP-input_data38-expected_data38] ✓53% █████▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A17E79C6D8DWNP-input_data39-expected_data39] ✓55% █████▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2NODRKZP88ZB9-input_data40-expected_data40] ✓56% █████▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2NODRKZP88ZB9-input_data41-expected_data41] ✓57% █████▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2NODRKZP88ZB9-input_data42-expected_data42] ✓58% █████▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2NODRKZP88ZB9-input_data43-expected_data43] ✓59% █████▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A33AVAJ2PDY3EV-input_data44-expected_data44] ✓60% ██████
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A33AVAJ2PDY3EV-input_data45-expected_data45] ✓61% ██████▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A33AVAJ2PDY3EV-input_data46-expected_data46] ✓62% ██████▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A33AVAJ2PDY3EV-input_data47-expected_data47] ✓64% ██████▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1F83G8C2ARO7P-input_data48-expected_data48] ✓65% ██████▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1F83G8C2ARO7P-input_data49-expected_data49] ✓66% ██████▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1F83G8C2ARO7P-input_data50-expected_data50] ✓67% ██████▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1F83G8C2ARO7P-input_data51-expected_data51] ✓68% ██████▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A39IBJ37TRP1C6-input_data52-expected_data52] ✓69% ██████▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A39IBJ37TRP1C6-input_data53-expected_data53] ✓70% ███████▏
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A39IBJ37TRP1C6-input_data54-expected_data54] ✓72% ███████▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A39IBJ37TRP1C6-input_data55-expected_data55] ✓73% ███████▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1VC38T7YXB528-input_data56-expected_data56] ✓74% ███████▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1VC38T7YXB528-input_data57-expected_data57] ✓75% ███████▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1VC38T7YXB528-input_data58-expected_data58] ✓76% ███████▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1VC38T7YXB528-input_data59-expected_data59] ✓77% ███████▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A19VAU5U5O7RUS-input_data60-expected_data60] ✓78% ███████▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A19VAU5U5O7RUS-input_data61-expected_data61] ✓80% ███████▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A19VAU5U5O7RUS-input_data62-expected_data62] ✓81% ████████▏
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A19VAU5U5O7RUS-input_data63-expected_data63] ✓82% ████████▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[ATVPDKIKX0DER-input_data64-expected_data64] ✓83% ████████▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[ATVPDKIKX0DER-input_data65-expected_data65] ✓84% ████████▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[ATVPDKIKX0DER-input_data66-expected_data66] ✓85% ████████▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[ATVPDKIKX0DER-input_data67-expected_data67] ✓86% ████████▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2Q3Y263D00KWC-input_data68-expected_data68] ✓88% ████████▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2Q3Y263D00KWC-input_data69-expected_data69] ✓89% ████████▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2Q3Y263D00KWC-input_data70-expected_data70] ✓90% █████████
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2Q3Y263D00KWC-input_data71-expected_data71] ✓91% █████████▏
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2EUQ1WTGCTBG2-input_data72-expected_data72] ✓92% █████████▎
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2EUQ1WTGCTBG2-input_data73-expected_data73] ✓93% █████████▍
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2EUQ1WTGCTBG2-input_data74-expected_data74] ✓94% █████████▌
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A2EUQ1WTGCTBG2-input_data75-expected_data75] ✓95% █████████▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1AM78C64UM0Y8-input_data76-expected_data76] ✓97% █████████▋
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1AM78C64UM0Y8-input_data77-expected_data77] ✓98% █████████▊
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1AM78C64UM0Y8-input_data78-expected_data78] ✓99% █████████▉
 airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_transform_function.py::test_transform_seller_feedback[A1AM78C64UM0Y8-input_data79-expected_data79] ✓100% ██████████
====================================================================================== warnings summary ======================================================================================
airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_streams
  /Users/ganpatagarwal/stoke/airbyte/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/source.py:111: DeprecationWarning: Call to deprecated class Oauth2Authenticator. (Use airbyte_cdk.sources.streams.http.requests_native_auth.Oauth2Authenticator instead) -- Deprecated since version 0.1.20.
    auth = AWSAuthenticator(

airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_streams
airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_streams
airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_streams
  /Users/ganpatagarwal/stoke/airbyte/airbyte-integrations/connectors/source-amazon-seller-partner/.venv/lib/python3.9/site-packages/deprecated/classic.py:173: DeprecationWarning: Call to deprecated class HttpAuthenticator. (Use requests.auth.AuthBase instead) -- Deprecated since version 0.1.20.
    return old_new1(cls, *args, **kwargs)

airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_streams
airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_source.py::test_streams
  /Users/ganpatagarwal/stoke/airbyte/airbyte-integrations/connectors/source-amazon-seller-partner/.venv/lib/python3.9/site-packages/airbyte_cdk/sources/streams/http/http.py:43: DeprecationWarning: Call to deprecated class NoAuth. (Set `authenticator=None` instead) -- Deprecated since version 0.1.20.
    self._authenticator: HttpAuthenticator = NoAuth()

-- Docs: https://docs.pytest.org/en/stable/warnings.html

Results (0.48s):
      88 passed
Integration
Test session starts (platform: darwin, Python 3.9.11, pytest 6.1.2, pytest-sugar 0.9.4)
cachedir: .pytest_cache
rootdir: /Users/ganpatagarwal/stoke/airbyte, configfile: pytest.ini
plugins: mock-3.7.0, sugar-0.9.4, timeout-1.4.2
collecting ...

Results (0.02s):
Acceptance
python -m pytest integration_tests -p integration_tests.acceptance
Test session starts (platform: darwin, Python 3.9.11, pytest 6.1.2, pytest-sugar 0.9.4)
cachedir: .pytest_cache
rootdir: /Users/ganpatagarwal/stoke/airbyte, configfile: pytest.ini
plugins: mock-3.7.0, sugar-0.9.4, timeout-1.4.2
collecting ...
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_config_match_spec[inputs0] ✓                                         6% ▋
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_match_expected[inputs0] ✓                                           12% █▎
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_docker_env[inputs0] ✓                                               18% █▊
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_oneof_usage[inputs0] ✓                                              24% ██▍
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_required[inputs0] ✓                                                 29% ██▉
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_optional[inputs0] ✓                                                 35% ███▌
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_has_secret[inputs0] ✓                                               41% ████▎
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_secret_never_in_the_output[inputs0] ✓                               47% ████▊
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_defined_refs_exist_in_json_spec_file[inputs0] ✓                     53% █████▍
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestSpec.test_oauth_flow_parameters[inputs0] ✓                                    59% █████▉
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestConnection.test_check[inputs0] ✓                                              65% ██████▌
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestDiscovery.test_discover[inputs0] ✓                                            71% ███████▏
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestDiscovery.test_defined_cursors_exist_in_schema[inputs0] ✓                     76% ███████▋
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestDiscovery.test_defined_refs_exist_in_schema[inputs0] ✓                        82% ████████▎
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestDiscovery.test_defined_keyword_exist_in_schema[inputs0-allOf] ✓               88% ████████▉
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestDiscovery.test_defined_keyword_exist_in_schema[inputs0-not] ✓                 94% █████████▌
 airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py::TestDiscovery.test_primary_keys_exist_in_schema[inputs0] ✓                       100% ██████████
{"type": "LOG", "log": {"level": "INFO", "message": "/Users/ganpatagarwal/stoke/airbyte/airbyte-integrations/connectors/source-amazon-seller-partner - SAT run - ee6ded358b22a8dfd3e4c24873062735ff35b7c1 - PASSED"}}

================================================================================== short test summary info ===================================================================================
SKIPPED [1] ../../bases/source-acceptance-test/source_acceptance_test/plugin.py:56: Skipping TestBasicRead.test_read because not found in the config
SKIPPED [1] ../../bases/source-acceptance-test/source_acceptance_test/plugin.py:56: Skipping TestFullRefresh.test_sequential_reads because not found in the config
SKIPPED [1] ../../bases/source-acceptance-test/source_acceptance_test/plugin.py:56: Skipping TestIncremental.test_two_sequential_reads because not found in the config

Results (20.81s):
      17 passed

@github-actions github-actions bot added the area/connectors Connector related issues label May 20, 2022
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label May 20, 2022
@alafanechere alafanechere self-assigned this May 20, 2022
Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution @ganpatagarwal
I've two main concerns:

  • I don't think it's good practice to ask users to manually set the value of this new field to default. I don't think your new fields requires a default, the connector should just handle a None value if the user does not set this field.
  • Setting a replication end date for an incremental streaùs mode sounds a bit awkward to me. What do you think about checking the stream sync mode and set the replication end date only when the sync mode is full refresh?

"pattern": "(^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$|default)",
"examples": ["default", "2017-02-25T00:00:00Z"],
"type": "string",
"default": "default"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to set a default, I'd suggest you remove the default value and handle it as a None value in the config parsing logic. Not required config option default to None if they are not set by the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None is much better than default 👍

Changes done

@@ -41,6 +41,7 @@ def __init__(
url_base: str,
aws_signature: AWSSignature,
replication_start_date: str,
replication_end_date: str,
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
replication_end_date: str,
replication_end_date: Optional[str],

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes are done !!

@@ -149,6 +161,7 @@ def __init__(
url_base: str,
aws_signature: AWSSignature,
replication_start_date: str,
replication_end_date: str,
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
replication_end_date: str,
replication_end_date: Optional[str],

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes are done !!

"reportType": self.name,
"marketplaceIds": [self.marketplace_id],
"dataStartTime": replication_start_date.strftime(DATE_TIME_FORMAT),
}

if is_valid_replication_end_date(self._replication_end_date):
params["dataEndTime"] = self._replication_end_date
params["dataStartTime"] = self._replication_start_date
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
params["dataStartTime"] = self._replication_start_date

Why are you setting the dataStartTime again? It's already set above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replication_start_date = max(pendulum.parse(self._replication_start_date), pendulum.now("utc").subtract(days=90))

With above logic, any start date older than 90 days would be overwritten.

If an user puts a start & end date older than 90 days, we would want to honour that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, could you please add a comment in the code to explain this logic?

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

return params

def parse_response(self, response: requests.Response, stream_state: Mapping[str, Any], **kwargs) -> Iterable[Mapping]:
yield from response.json().get(self.data_field, {}).get("shippingLabels", [])


def is_valid_replication_end_date(custom_date: str) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this function should exist, the regex pattern in the spec.json should already guarantee a valid input.
If you still think this is required, please call this function once in the __init__ of the stream class, avoid calling it multiple times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

totally agree!!

have removed it

@alafanechere
Copy link
Contributor

alafanechere commented May 23, 2022

/test connector=connectors/source-amazon-seller-partner

🕑 connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2370595925
✅ connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2370595925
Python tests coverage:

Name                                                 Stmts   Miss  Cover
------------------------------------------------------------------------
source_acceptance_test/utils/__init__.py                 6      0   100%
source_acceptance_test/tests/__init__.py                 4      0   100%
source_acceptance_test/__init__.py                       2      0   100%
source_acceptance_test/tests/test_full_refresh.py       52      2    96%
source_acceptance_test/utils/asserts.py                 37      2    95%
source_acceptance_test/config.py                        77      6    92%
source_acceptance_test/utils/json_schema_helper.py     105     13    88%
source_acceptance_test/tests/test_incremental.py       121     25    79%
source_acceptance_test/utils/common.py                  80     17    79%
source_acceptance_test/tests/test_core.py              294    106    64%
source_acceptance_test/utils/compare.py                 62     23    63%
source_acceptance_test/base.py                          10      4    60%
source_acceptance_test/utils/connector_runner.py       110     48    56%
------------------------------------------------------------------------
TOTAL                                                  960    246    74%
Name                                        Stmts   Miss  Cover
---------------------------------------------------------------
source_amazon_seller_partner/__init__.py        2      0   100%
source_amazon_seller_partner/constants.py      37      1    97%
source_amazon_seller_partner/source.py         65      9    86%
source_amazon_seller_partner/streams.py       383    183    52%
source_amazon_seller_partner/auth.py           61     36    41%
---------------------------------------------------------------
TOTAL                                         548    229    58%

Python short test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:56: Skipping TestBasicRead.test_read because not found in the config
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:56: Skipping TestFullRefresh.test_sequential_reads because not found in the config
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:56: Skipping TestIncremental.test_two_sequential_reads because not found in the config
======================== 17 passed, 3 skipped in 5.88s =========================

@alafanechere
Copy link
Contributor

I'm requesting a review from @misteryeo as this PR is touching the spec.json file.

Copy link
Contributor Author

@ganpatagarwal ganpatagarwal left a comment

Choose a reason for hiding this comment

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

Thanks @alafanechere for the review.

I have tried to incorporate the suggested changes. PTAL

"pattern": "(^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$|default)",
"examples": ["default", "2017-02-25T00:00:00Z"],
"type": "string",
"default": "default"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

None is much better than default 👍

Changes done

@@ -41,6 +41,7 @@ def __init__(
url_base: str,
aws_signature: AWSSignature,
replication_start_date: str,
replication_end_date: str,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes are done !!

@@ -149,6 +161,7 @@ def __init__(
url_base: str,
aws_signature: AWSSignature,
replication_start_date: str,
replication_end_date: str,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes are done !!

"reportType": self.name,
"marketplaceIds": [self.marketplace_id],
"dataStartTime": replication_start_date.strftime(DATE_TIME_FORMAT),
}

if is_valid_replication_end_date(self._replication_end_date):
params["dataEndTime"] = self._replication_end_date
params["dataStartTime"] = self._replication_start_date
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replication_start_date = max(pendulum.parse(self._replication_start_date), pendulum.now("utc").subtract(days=90))

With above logic, any start date older than 90 days would be overwritten.

If an user puts a start & end date older than 90 days, we would want to honour that.

return params

def parse_response(self, response: requests.Response, stream_state: Mapping[str, Any], **kwargs) -> Iterable[Mapping]:
yield from response.json().get(self.data_field, {}).get("shippingLabels", [])


def is_valid_replication_end_date(custom_date: str) -> bool:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

totally agree!!

have removed it

Comment on lines 707 to 734
params.update({"createdBefore": pendulum.now("utc").strftime(self.time_format)})
end_date = pendulum.now("utc").strftime(self.time_format)
if self._replication_end_date:
end_date = self._replication_end_date
params.update({self.replication_end_date_field: end_date})
Copy link
Contributor

Choose a reason for hiding this comment

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

On this stream the replication_start_date_field might be automatically set compared to now because The date range to search must not be more than 7 days.
I think you might also need to change the computation of the replication_start_date_field in the __init__ if _replication_end_date is set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After giving a closer look, I doubt that this API ever worked on Airbyte.
We are not setting createdAfter request parameter, which is required

https://sellingpartnerapi-na.amazon.com/vendor/directFulfillment/shipping/v1/shippingLabels?createdBefore=2022-05-24T10%3A26%3A22Z

self.replication_start_date_field = max(...)
This code is overwriting the value createdAfter, which should have been used to set request params.

We should move the logic to calculate start date to request_params(...) along with calculation and setting end date

Please let me know if my observation is correct and will make the necessary changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made the changes. Please review and share your thoughts.

@alafanechere
Copy link
Contributor

alafanechere commented May 24, 2022

/test connector=connectors/source-amazon-seller-partner

🕑 connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2376787332
✅ connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2376787332
Python tests coverage:

Name                                                 Stmts   Miss  Cover
------------------------------------------------------------------------
source_acceptance_test/utils/__init__.py                 6      0   100%
source_acceptance_test/tests/__init__.py                 4      0   100%
source_acceptance_test/__init__.py                       2      0   100%
source_acceptance_test/tests/test_full_refresh.py       52      2    96%
source_acceptance_test/utils/asserts.py                 37      2    95%
source_acceptance_test/config.py                        77      6    92%
source_acceptance_test/utils/json_schema_helper.py     105     13    88%
source_acceptance_test/tests/test_incremental.py       121     25    79%
source_acceptance_test/utils/common.py                  80     17    79%
source_acceptance_test/tests/test_core.py              294    106    64%
source_acceptance_test/utils/compare.py                 62     23    63%
source_acceptance_test/base.py                          10      4    60%
source_acceptance_test/utils/connector_runner.py       110     48    56%
------------------------------------------------------------------------
TOTAL                                                  960    246    74%
Name                                        Stmts   Miss  Cover
---------------------------------------------------------------
source_amazon_seller_partner/__init__.py        2      0   100%
source_amazon_seller_partner/constants.py      37      1    97%
source_amazon_seller_partner/source.py         65      9    86%
source_amazon_seller_partner/streams.py       384    181    53%
source_amazon_seller_partner/auth.py           61     36    41%
---------------------------------------------------------------
TOTAL                                         549    227    59%

@alafanechere
Copy link
Contributor

alafanechere commented May 24, 2022

@ganpatagarwal thank you for the changes you made. I made a final change request above.
I'll be off until next Monday from tomorrow so bear with me if there is a delay reviewing your upcoming changes.

@alafanechere
Copy link
Contributor

alafanechere commented May 30, 2022

/test connector=connectors/source-amazon-seller-partner

🕑 connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2408569345
✅ connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2408569345
Python tests coverage:

Name                                                 Stmts   Miss  Cover
------------------------------------------------------------------------
source_acceptance_test/utils/__init__.py                 6      0   100%
source_acceptance_test/tests/__init__.py                 4      0   100%
source_acceptance_test/__init__.py                       2      0   100%
source_acceptance_test/tests/test_full_refresh.py       52      2    96%
source_acceptance_test/utils/asserts.py                 37      2    95%
source_acceptance_test/config.py                        77      6    92%
source_acceptance_test/utils/json_schema_helper.py     105     13    88%
source_acceptance_test/tests/test_incremental.py       121     25    79%
source_acceptance_test/utils/common.py                  80     17    79%
source_acceptance_test/tests/test_core.py              294    106    64%
source_acceptance_test/utils/compare.py                 62     23    63%
source_acceptance_test/base.py                          10      4    60%
source_acceptance_test/utils/connector_runner.py       110     48    56%
------------------------------------------------------------------------
TOTAL                                                  960    246    74%
Name                                        Stmts   Miss  Cover
---------------------------------------------------------------
source_amazon_seller_partner/__init__.py        2      0   100%
source_amazon_seller_partner/constants.py      37      1    97%
source_amazon_seller_partner/source.py         65      9    86%
source_amazon_seller_partner/streams.py       382    182    52%
source_amazon_seller_partner/auth.py           61     36    41%
---------------------------------------------------------------
TOTAL                                         547    228    58%

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:56: Skipping TestBasicRead.test_read because not found in the config
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:56: Skipping TestFullRefresh.test_sequential_reads because not found in the config
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:56: Skipping TestIncremental.test_two_sequential_reads because not found in the config
======================== 17 passed, 3 skipped in 5.77s =========================

Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

Thank you for the change @ganpatagarwal . I made an additional minor change to the pattern to copy the existing pattern on start date.

@alafanechere
Copy link
Contributor

alafanechere commented May 30, 2022

/publish connector=connectors/source-amazon-seller-partner

🕑 connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2409647323
❌ Failed to publish connectors/source-amazon-seller-partner
❌ Couldn't auto-bump version for connectors/source-amazon-seller-partner
🕑 connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2409647323
❌ Failed to publish connectors/source-amazon-seller-partner
❌ Couldn't auto-bump version for connectors/source-amazon-seller-partner
🕑 connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2409647323
❌ Failed to publish connectors/source-amazon-seller-partner
❌ Couldn't auto-bump version for connectors/source-amazon-seller-partner
🕑 connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2409647323
🚀 Successfully published connectors/source-amazon-seller-partner
🚀 Auto-bumped version for connectors/source-amazon-seller-partner
✅ connectors/source-amazon-seller-partner https://github.com/airbytehq/airbyte/actions/runs/2409647323

@alafanechere alafanechere merged commit 2293f89 into airbytehq:master May 30, 2022
@ganpatagarwal ganpatagarwal deleted the amazon-seller-partner-end-date branch May 31, 2022 03:52
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 community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants