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 Facebook Marketing: Add lookback window to insights streams #12402

Conversation

vladimir-remar
Copy link
Contributor

What

Bring back the possibility to set up an attribution window.
Let say the users will not use all the data retrieve from the insight stream and just use part of it (e.g., spend) in some cases
set a looback_window short than 28 days would help the users by reducing the sync time.

How

Set value for insights_lookback_window throught config.

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

Expand the relevant checklist and delete the others.

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

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 the area/connectors Connector related issues label Apr 27, 2022
@vladimir-remar
Copy link
Contributor Author

@sherifnada I made this Draft related to #9805

@vladimir-remar vladimir-remar changed the title Add lookback window to insgiths streams Source Facebook Marketing: Add lookback window to insgiths streams Apr 28, 2022
@marcosmarxm
Copy link
Member

@vladimir-remar this is ready to review?

@marcosmarxm
Copy link
Member

@lazebnyi can you check the implementation @vladimir-remar is doing for Facebook Marketing?

@@ -147,3 +147,13 @@ class Config:
"A list which contains insights entries, each entry must have a name and can contains fields, breakdowns or action_breakdowns)"
),
)

insights_lookback_window: Optional[PositiveInt] = Field(
Copy link
Contributor

Choose a reason for hiding this comment

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

we should make this default_insights_lookback_window and apply it only to the default insights synced by this connector, and separately we should allow configuring this on a per-insight level in the custom insights

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for your patience I will work on this ASAP.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @vladimir-remar I'm not sure you ended up implementing @sherifnada suggestion. Is anything blocking you from going in the suggested direction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @alafanechere, maybe I'm wrong, I just replicate the same approach in the custom insight part.

insights_lookback_window: Optional[PositiveInt] = Field(

@CLAassistant
Copy link

CLAassistant commented May 5, 2022

CLA assistant check
All committers have signed the CLA.

@vladimir-remar vladimir-remar marked this pull request as ready for review May 10, 2022 11:56
@alafanechere alafanechere self-assigned this May 16, 2022
@@ -147,3 +147,13 @@ class Config:
"A list which contains insights entries, each entry must have a name and can contains fields, breakdowns or action_breakdowns)"
),
)

insights_lookback_window: Optional[PositiveInt] = Field(
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @vladimir-remar I'm not sure you ended up implementing @sherifnada suggestion. Is anything blocking you from going in the suggested direction?

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.

@vladimir-remar I think you're right, @sherifnada's concern is addressed, 👍 I'm requesting change as I think you need to update unit tests to cover your changes. This connector is in General Availability, meaning we are quite strict in terms of coverage. Could you please bump the connector version in the Dockerfile and update the changelog in facebook-marketing.md?

@alafanechere
Copy link
Contributor

I would also need an additional review from @sherifnada or @lazebnyi 🙏

@alafanechere
Copy link
Contributor

alafanechere commented May 18, 2022

/test connector=connectors/source-facebook-marketing

🕑 connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/2346152756
❌ connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/2346152756
🐛 https://gradle.com/s/gghga2qcl74iw

@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label May 19, 2022
@lazebnyi lazebnyi requested review from grubberr and removed request for lazebnyi May 19, 2022 12:31
@lazebnyi
Copy link
Collaborator

@alafanechere I think @grubberr can help with review. Already discussed with him about that. He working now on FB marketing.

@grubberr
Copy link
Contributor

@vladimir-remar please also fix unit_tests

pytest unit_tests


Results (1.28s):
      82 passed
      16 failed

@grubberr
Copy link
Contributor

grubberr commented May 24, 2022

/test connector=connectors/source-facebook-marketing

🕑 connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/2376340659
❌ connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/2376340659
🐛 https://gradle.com/s/ke2czo2he57ws

Build Failed

Test summary info:

	 =========================== short test summary info ============================
	 FAILED unit_tests/test_base_insight_streams.py::TestBaseInsightsStream::test_stream_slices_no_state
	 FAILED unit_tests/test_base_insight_streams.py::TestBaseInsightsStream::test_stream_slices_no_state_close_to_now
	 FAILED unit_tests/test_base_insight_streams.py::TestBaseInsightsStream::test_stream_slices_with_state
	 FAILED unit_tests/test_base_insight_streams.py::TestBaseInsightsStream::test_stream_slices_with_state_close_to_now
	 FAILED unit_tests/test_base_insight_streams.py::TestBaseInsightsStream::test_stream_slices_with_state_and_slices
	 FAILED unit_tests/test_base_insight_streams.py::TestBaseInsightsStream::test_completed_slices_in_lookback_period
	 FAILED unit_tests/test_base_insight_streams.py::TestBaseInsightsStream::test_incremental_lookback_period_updated
	 �[31m========================= �[31m�[1m7 failed�[0m, �[32m93 passed�[0m�[31m in 1.47s�[0m�[31m =========================�[0m

@alafanechere
Copy link
Contributor

Hey @grubberr do you have an idea why tests are failing now after passing yesterday? Did you merge master in the branch?
@vladimir-remar I will be off until next Monday, bare with me for the review delay. @grubberr feel free to proceed to publish and merge once we get a review from @misteryeo .

@vladimir-remar
Copy link
Contributor Author

vladimir-remar commented May 24, 2022

Hey @grubberr do you have an idea why tests are failing now after passing yesterday? Did you merge master in the branch? @vladimir-remar I will be off until next Monday, bare with me for the review delay. @grubberr feel free to proceed to publish and merge once we get a review from @misteryeo .

@alafanechere Yes I did today after see the conflict.

@grubberr
Copy link
Contributor

@vladimir-remar I think unit_tests failed because the master branch changed and you need to synchronise your code base with the latest updates in the master

@grubberr
Copy link
Contributor

grubberr commented May 24, 2022

/test connector=connectors/source-facebook-marketing

🕑 connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/2378940847
✅ connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/2378940847
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_facebook_marketing/streams/__init__.py                   2      0   100%
source_facebook_marketing/spec.py                              36      0   100%
source_facebook_marketing/__init__.py                           2      0   100%
source_facebook_marketing/api.py                               96     12    88%
source_facebook_marketing/streams/base_streams.py             127     27    79%
source_facebook_marketing/streams/common.py                    41     13    68%
source_facebook_marketing/streams/streams.py                   97     32    67%
source_facebook_marketing/source.py                            39     16    59%
source_facebook_marketing/streams/base_insight_streams.py     147     69    53%
source_facebook_marketing/streams/async_job.py                210    134    36%
source_facebook_marketing/streams/async_job_manager.py         78     60    23%
-------------------------------------------------------------------------------
TOTAL                                                         875    363    59%
Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
source_facebook_marketing/streams/async_job.py                210      0   100%
source_facebook_marketing/streams/__init__.py                   2      0   100%
source_facebook_marketing/spec.py                              36      0   100%
source_facebook_marketing/__init__.py                           2      0   100%
source_facebook_marketing/streams/common.py                    41      1    98%
source_facebook_marketing/source.py                            39      1    97%
source_facebook_marketing/streams/async_job_manager.py         78      3    96%
source_facebook_marketing/streams/base_insight_streams.py     147      6    96%
source_facebook_marketing/api.py                               96      9    91%
source_facebook_marketing/streams/streams.py                   97     22    77%
source_facebook_marketing/streams/base_streams.py             127     30    76%
-------------------------------------------------------------------------------
TOTAL                                                         875     72    92%

Build Passed

Test summary info:

All Passed

@grubberr
Copy link
Contributor

grubberr commented May 25, 2022

/test connector=connectors/source-facebook-marketing

🕑 connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/2383206314
✅ connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/2383206314
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_facebook_marketing/streams/__init__.py                   2      0   100%
source_facebook_marketing/spec.py                              36      0   100%
source_facebook_marketing/__init__.py                           2      0   100%
source_facebook_marketing/api.py                               96     12    88%
source_facebook_marketing/streams/base_streams.py             127     27    79%
source_facebook_marketing/streams/common.py                    41     13    68%
source_facebook_marketing/streams/streams.py                   97     32    67%
source_facebook_marketing/source.py                            39     16    59%
source_facebook_marketing/streams/base_insight_streams.py     147     69    53%
source_facebook_marketing/streams/async_job.py                210    134    36%
source_facebook_marketing/streams/async_job_manager.py         78     60    23%
-------------------------------------------------------------------------------
TOTAL                                                         875    363    59%
Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
source_facebook_marketing/streams/async_job.py                210      0   100%
source_facebook_marketing/streams/__init__.py                   2      0   100%
source_facebook_marketing/spec.py                              36      0   100%
source_facebook_marketing/__init__.py                           2      0   100%
source_facebook_marketing/streams/common.py                    41      1    98%
source_facebook_marketing/source.py                            39      1    97%
source_facebook_marketing/streams/async_job_manager.py         78      3    96%
source_facebook_marketing/streams/base_insight_streams.py     147      6    96%
source_facebook_marketing/api.py                               96      9    91%
source_facebook_marketing/streams/streams.py                   97     22    77%
source_facebook_marketing/streams/base_streams.py             127     30    76%
-------------------------------------------------------------------------------
TOTAL                                                         875     72    92%

Build Passed

Test summary info:

All Passed

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 @grubberr for the review and @vladimir-remar for the changes! I'm now waiting for @misteryeo approval to publish and merge.

@alafanechere
Copy link
Contributor

alafanechere commented May 31, 2022

/publish connector=connectors/source-facebook-marketing

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

@alafanechere
Copy link
Contributor

Thank you @vladimir-remar for the contribution! The new connector version is now published and I'm going to merge this PR.

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

Successfully merging this pull request may close these issues.

None yet

9 participants