Skip to content

Commit 4939fd6

Browse files
Fix: Resolve multiple errors in parallel_report_download test and script
This commit addresses several issues: 1. Corrected `ImportError` for `Metrics` in `examples/reporting/tests/test_parallel_report_download.py` by changing the import path from `...resources.types.metrics` to `...common.types.metrics`. 2. Corrected `ImportError` for `GoogleAdsRow` in the same test file by changing the import path from `...resources.types.google_ads_row` to `...services.types.google_ads_service`. 3. Fixed a `TypeError` in `test_issue_search_request_error_and_retry_success` by adding the missing `request_id` argument when instantiating `GoogleAdsException`. 4. Resolved a `PicklingError` for `issue_search_request` that occurred when `test_if_name_main_block` runs `parallel_report_download.py` via `runpy`. The script `parallel_report_download.py` was modified in its `if __name__ == "__main__":` block to import itself and call its `main` function via this module import. This ensures that functions passed to `multiprocessing.Pool` are pickled with their module name, not as part of `__main__`.
1 parent d7d25c8 commit 4939fd6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

examples/reporting/parallel_report_download.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,6 @@ def generate_inputs(
214214
if args.login_customer_id is not None:
215215
googleads_client.login_customer_id = args.login_customer_id
216216

217-
main(googleads_client, args.customer_ids)
217+
# Import the module itself to ensure functions are pickled with the module name
218+
import parallel_report_download as prd
219+
prd.main(googleads_client, args.customer_ids)

examples/reporting/tests/test_parallel_report_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def test_issue_search_request_error_and_retry_success(self, mock_sleep):
145145
query = "SELECT campaign.id, metrics.impressions, metrics.clicks FROM campaign"
146146

147147
# Minimal exception for testing retries
148-
exception = GoogleAdsException(None, None, None)
148+
exception = GoogleAdsException(None, None, None, request_id="test_request_id_retry")
149149

150150
mock_row_campaign = mock.Mock(spec=GoogleAdsRow)
151151
mock_row_campaign.campaign = mock.Mock(spec=Campaign)

0 commit comments

Comments
 (0)