Skip to content

Commit 37833b8

Browse files
Add new libraries to daily data collection (#9)
* Add additional libraries to the download analytics collection * Fix daily build * Use fixed httplib2 version * Improve way of inserting columns * Update metrics.py * Update metrics.py
1 parent 9f9b54d commit 37833b8

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ projects:
1414
- datomize
1515
- gretel-trainer
1616
- ydata-sdk
17+
- mostlyai
18+
- synthcity
19+
- smartnoise-synth
20+
- realtabformer
21+
- be-great

download_analytics/metrics.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,20 @@ def _historical_groupby(downloads, groupbys=None):
3535
if groupbys is None:
3636
groupbys = downloads.set_index('timestamp').columns
3737

38+
new_columns = []
3839
for groupby in groupbys:
3940
grouped = downloads.groupby([year_month, groupby])
4041
grouped_sizes = grouped.size().unstack(-1) # noqa: PD010
4142
if len(groupbys) > 1:
4243
grouped_sizes.columns = f"{groupby}='" + grouped_sizes.columns + "'"
44+
new_columns.append(grouped_sizes.fillna(0))
4345

44-
base[grouped_sizes.columns] = grouped_sizes.fillna(0)
46+
if new_columns:
47+
base = pd.concat([base] + new_columns, axis=1)
4548

4649
totals = base.sum()
4750
totals.name = 'total'
48-
base = pd.concat([base, totals], ignore_index=True)
51+
base = pd.concat([base, totals.to_frame().T], ignore_index=True)
4952

5053
return base.reset_index().iloc[::-1]
5154

download_analytics/pypi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def get_pypi_downloads(
150150
if max_date is None:
151151
all_downloads = new_downloads
152152
else:
153-
if max_date < end_date:
153+
if pd.Timestamp(max_date) < pd.Timestamp(end_date):
154154
before = previous[previous.timestamp < new_downloads.timestamp.min()]
155155
after = new_downloads
156156
else:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ dependencies = [
2121
"PyYAML",
2222
"PyDrive",
2323
"google-cloud-bigquery",
24-
"db-dtypes"
24+
"db-dtypes",
25+
"httplib2==0.15.0", # https://stackoverflow.com/questions/59815620/gcloud-upload-httplib2-redirectmissinglocation-redirected-but-the-response-is-m
2526
]
2627

2728
[project.urls]

0 commit comments

Comments
 (0)