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 learning_stage_info field to AdSets stream #50418

Merged
merged 11 commits into from
Mar 11, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: e7778cfc-e97c-4458-9ecb-b4f2bba8946c
dockerImageTag: 3.3.34
dockerImageTag: 3.4.0
dockerRepository: airbyte/source-facebook-marketing
documentationUrl: https://docs.airbyte.com/integrations/sources/facebook-marketing
githubIssueLabel: source-facebook-marketing
Expand Down
131 changes: 112 additions & 19 deletions airbyte-integrations/connectors/source-facebook-marketing/poetry.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
version = "3.3.34"
version = "3.4.0"
name = "source-facebook-marketing"
description = "Source implementation for Facebook Marketing."
authors = [ "Airbyte <contact@airbyte.io>",]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,32 @@
}
}
}
},
"learning_stage_info": {
"description": "Info about whether the ranking or delivery system is still learning for this ad set.",
"type": ["null", "object"],
"properties": {
"status": {
"description": "Learning Phase progress for the ad set. Values: LEARNING — The ad set is still learning. SUCCESS — The ad set exited the learning phase. FAIL — The ad set isn’t generating enough results to exit the learning phase.",
"type": ["null", "string"]
},
"conversions": {
"description": "Number of conversions the ad set generated since the time of its last significant edit during the learning phase. Significant edits cause ad sets to reenter the learning phase.",
"type": ["null", "integer"]
},
"last_sig_edit_ts": {
"description": "Timestamp of the last significant edit that caused ad set to reenter the learning phase.",
"type": ["null", "integer"]
},
"attribution_windows": {
"description": "List of configured attribution windows.",
"type": ["null", "array"],
"items": {
"description": "Number of days between when a person viewed or clicked your ad and subsequently took action. By default, the attribution window is set to 1-day view and 28-day click.",
"type": ["null", "string"]
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def test_ad_sets_stream(self, http_mocker: HttpMocker):
"bid_amount",
"bid_constraints",
"adlabels",
"learning_stage_info",
]

http_mocker.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
"REACH": 99
},
"bid_strategy": "COST_CAP",
"bid_amount": 99.0
"bid_amount": 99.0,
"learning_stage_info": {
"status": "LEARNING",
"conversions": 12,
"last_sig_edit_ts": 1734947501,
"attribution_windows": ["7d_click", "1d_view"]
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,16 @@ def test_get_result_retried(self, mocker, job, api):
api.call().json.return_value = {"data": [{"some_data": 123}, {"some_data": 77}]}
ads_insights = AdsInsights(api=api)
ads_insights._set_data({"items": [{"some_data": 123}, {"some_data": 77}]})
with mocker.patch(
mocker.patch(
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to remove context manager here?

Copy link
Contributor Author

@h0rban h0rban Mar 10, 2025

Choose a reason for hiding this comment

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

@artem1205, i am seeing the following warning when running unit tests with the previous version.

airbyte-integrations/connectors/source-facebook-marketing/unit_tests/test_async_job.py::TestInsightAsyncJob::test_get_result_retried
  xxx/airbyte/airbyte-integrations/connectors/source-facebook-marketing/unit_tests/test_async_job.py:337: PytestMockWarning: Mocks returned by pytest-mock do not need to be used as context managers. The mocker fixture automatically undoes mocking at the end of a test. This warning can be ignored if it was triggered by mocking a context manager. https://pytest-mock.readthedocs.io/en/latest/remarks.html#usage-as-context-manager
    with mocker.patch(

Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL, thanks for the explanation @h0rban !

"facebook_business.adobjects.objectparser.ObjectParser.parse_multiple",
side_effect=[
FacebookBadObjectError("Bad data to set object data"),
ads_insights,
],
):
# in case this is not retried, an error will be raised
job.get_result()
)

# in case this is not retried, an error will be raised
job.get_result()

def test_get_result_when_job_is_not_started(self, job):
with pytest.raises(
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/facebook-marketing.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ This response indicates that the Facebook Graph API requires you to reduce the f

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 3.4.0 | 2024-12-24 | [50418](https://github.com/airbytehq/airbyte/pull/50418) | Add `learning_stage_info` field to `ad_sets` stream |
| 3.3.34 | 2025-03-01 | [54990](https://github.com/airbytehq/airbyte/pull/54990) | Update dependencies |
| 3.3.33 | 2025-02-22 | [54386](https://github.com/airbytehq/airbyte/pull/54386) | Update dependencies |
| 3.3.32 | 2025-02-15 | [53721](https://github.com/airbytehq/airbyte/pull/53721) | Update dependencies |
Expand Down
Loading