Skip to content

Commit ccbc3d3

Browse files
[ads] fix: add missing tenacity dependency
1 parent f1718db commit ccbc3d3

File tree

5 files changed

+103
-8
lines changed

5 files changed

+103
-8
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish to PyPI - garf-google-ads
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'libs/community/google/ads/**'
9+
- '!libs/community/google/ads/*.md'
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: pypi
16+
permissions:
17+
id-token: write
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v4
25+
26+
- name: Get versions and check for change
27+
id: version_check
28+
run: |
29+
PREV_VERSION=$(git show HEAD~1:libs/community/google/ads/garf_google_ads/__init__.py | grep -oE "__version__ = '([0-9]+\.[0-9]+\.[0-9]+)'" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
30+
CURRENT_VERSION=$(grep -oE "__version__ = '([0-9]+\.[0-9]+\.[0-9]+)'" libs/community/google/ads/garf_google_ads/__init__.py | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
31+
32+
if [[ "$CURRENT_VERSION" != "$PREV_VERSION" ]]; then
33+
echo "Version change detected: $PREV_VERSION -> $CURRENT_VERSION"
34+
echo "should_publish=true" >> $GITHUB_OUTPUT
35+
echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
36+
else
37+
echo "No version change. Skipping publish."
38+
echo "should_publish=false" >> $GITHUB_OUTPUT
39+
fi
40+
41+
- name: Build the package
42+
if: steps.version_check.outputs.should_publish == 'true'
43+
run: uv build libs/community/google/ads/
44+
45+
- name: Publish to PyPI
46+
if: steps.version_check.outputs.should_publish == 'true'
47+
run: uv publish libs/community/google/ads/dist/*
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Run tests for garf-google-ads
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- 'libs/community/google/ads/garf_google_ads/**'
9+
10+
env:
11+
UV_SYSTEM_PYTHON: 1
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up Python 3.13
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.13"
22+
- name: Setup uv
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
version: "0.5.4"
26+
enable-cache: true
27+
- name: Install dependencies
28+
run: |
29+
uv pip install pytest
30+
- name: Test ${{ matrix.library }}
31+
run: |
32+
cd libs/community/google/ads/
33+
uv pip install -e .
34+
pytest tests/unit

libs/community/google/ads/garf_google_ads/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
'GoogleAdsApiReportFetcher',
2323
]
2424

25-
__version__ = '0.0.1'
25+
__version__ = '0.0.2'

libs/community/google/ads/garf_google_ads/report_fetcher.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ def fetch(
5252
customer_ids_query: str | None = None,
5353
**kwargs: str,
5454
) -> garf_core.GarfReport:
55+
"""Fetches data from Google Ads API.
56+
57+
Args:
58+
query_specifiction: Query to execute.
59+
args: Optional parameters to fine-tune the query.
60+
account: Account(s) to get data from.
61+
expand_mcc: Whether to perform account expansion (MCC to Account).
62+
custom_ids_query: Query to reduce number of accounts based a condition.
63+
64+
Returns:
65+
Fetched report for provided accounts.
66+
"""
5567
if isinstance(account, str):
5668
account = account.split(',')
5769
if not args:
@@ -102,14 +114,11 @@ def expand_mcc(
102114
"""Performs Manager account(s) expansion to child accounts.
103115
104116
Args:
105-
customer_ids:
106-
Manager account(s) to be expanded.
107-
customer_ids_query:
108-
Garf query to limit the expansion only to accounts
109-
satisfying the condition.
117+
customer_ids: Manager account(s) to be expanded.
118+
customer_ids_query: GAQL query used to reduce the number of customer_ids.
110119
111120
Returns:
112-
All child accounts under provided customer_ids.
121+
All child accounts under provided customer_ids.
113122
"""
114123
return self._get_customer_ids(
115124
seed_customer_ids=customer_ids, customer_ids_query=customer_ids_query
@@ -127,7 +136,7 @@ def _get_customer_ids(
127136
customer_ids_query: GAQL query used to reduce the number of customer_ids.
128137
129138
Returns:
130-
All customer_ids from MCC satisfying the condition.
139+
All customer_ids from MCC satisfying the condition.
131140
"""
132141
query = """
133142
SELECT customer_client.id FROM customer_client

libs/community/google/ads/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies = [
88
"garf-core",
99
"garf-io",
1010
"google-ads",
11+
"tenacity",
1112
]
1213
authors = [
1314
{name = "Andrei Markin", email = "amarkin@google.com"},
@@ -36,3 +37,7 @@ test = [
3637
"pytest-cov",
3738
"python-dotenv",
3839
]
40+
41+
[[tool.uv.index]]
42+
url = "https://pypi.org/simple"
43+
default = true

0 commit comments

Comments
 (0)