Skip to content

Commit 78def40

Browse files
committed
Fix recommendations examples
Change-Id: I3631fb0deb73ec29bcf3a85372ce50d828ebc98f
1 parent 14c8374 commit 78def40

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

examples/recommendations/detect_and_apply_recommendations.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131

3232
import argparse
3333
import sys
34-
from typing import List
34+
from typing import List, Iterable
3535

3636
from google.ads.googleads.client import GoogleAdsClient
3737
from google.ads.googleads.errors import GoogleAdsException
38-
from google.ads.googleads.v20.services.types.google_ads_service import GoogleAdsRow
38+
from google.ads.googleads.v20.services.types.google_ads_service import (
39+
GoogleAdsRow,
40+
)
3941
from google.ads.googleads.v20.services.types.recommendation_service import (
4042
ApplyRecommendationOperation,
4143
ApplyRecommendationResult,
@@ -187,13 +189,9 @@ def apply_recommendations(
187189

188190
# GoogleAdsClient will read the google-ads.yaml configuration file in the
189191
# home directory if none is specified.
190-
<<<<<<< HEAD
191-
googleads_client = GoogleAdsClient.load_from_storage(version="v20")
192-
=======
193192
googleads_client: GoogleAdsClient = GoogleAdsClient.load_from_storage(
194193
version="v20"
195194
)
196-
>>>>>>> a90c77484 (I've added type hints to the examples/recommendations directory.)
197195

198196
try:
199197
main(googleads_client, args.customer_id)

examples/recommendations/generate_budget_recommendations.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@
3131

3232
from google.ads.googleads.client import GoogleAdsClient
3333
from google.ads.googleads.errors import GoogleAdsException
34-
from google.ads.googleads.v18.services.services.recommendation_service import (
34+
from google.ads.googleads.v20.services.services.recommendation_service import (
3535
RecommendationServiceClient,
3636
)
37-
from google.ads.googleads.v18.services.types.recommendation_service import (
37+
from google.ads.googleads.v20.services.types.recommendation_service import (
3838
GenerateRecommendationsRequest,
3939
GenerateRecommendationsResponse,
4040
)
41-
from google.ads.googleads.v18.resources.types.recommendation import Recommendation
41+
from google.ads.googleads.v20.resources.types.recommendation import (
42+
Recommendation,
43+
)
4244

4345

4446
def main(client: GoogleAdsClient, customer_id: str) -> None:
@@ -92,7 +94,9 @@ def main(client: GoogleAdsClient, customer_id: str) -> None:
9294
"potential_metrics": impact.potential_metrics,
9395
}
9496
budget_recommendations_list.append(budget_data)
95-
budget_amounts.append(round((budget_amount_micros / 1000000), 2))
97+
budget_amounts.append(
98+
round((budget_amount_micros / 1000000), 2)
99+
)
96100

97101
print(f"budget_recommendations_list:\n{budget_recommendations_list}")
98102
"""

examples/recommendations/get_recommendation_impact_metrics.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@
3131

3232
from google.ads.googleads.client import GoogleAdsClient
3333
from google.ads.googleads.errors import GoogleAdsException
34-
from google.ads.googleads.v18.services.services.recommendation_service import (
34+
from google.ads.googleads.v20.services.services.recommendation_service import (
3535
RecommendationServiceClient,
3636
)
37-
from google.ads.googleads.v18.services.types.recommendation_service import (
37+
from google.ads.googleads.v20.services.types.recommendation_service import (
3838
GenerateRecommendationsRequest,
3939
GenerateRecommendationsResponse,
4040
)
41-
from google.ads.googleads.v18.resources.types.recommendation import Recommendation
41+
from google.ads.googleads.v20.resources.types.recommendation import (
42+
Recommendation,
43+
)
4244

4345

4446
def main(
@@ -92,7 +94,10 @@ def main(
9294
if hasattr(budget_option, "impact"):
9395
impact = budget_option.impact
9496
budget_amount_micros = budget_option.budget_amount_micros
95-
if budget_amount_micros / 1000000 == user_provided_budget_amount:
97+
if (
98+
budget_amount_micros / 1000000
99+
== user_provided_budget_amount
100+
):
96101
budget_data: Dict[str, Any] = {
97102
"budget_amount": round(
98103
(budget_amount_micros / 1000000), 2

0 commit comments

Comments
 (0)