-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automate pypi statistics tracking and figure updates
* deleting the pypistat ipynb as functionality is moved to a script * add action to run script monthly
- Loading branch information
1 parent
157bba5
commit a9c7813
Showing
3 changed files
with
78 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Get PyPi Stats | ||
on: | ||
schedule: | ||
# runs once a month on the first | ||
- cron: "55 20 1 * *" | ||
# Trigger manually at https://github.com/icesat2py/icepyx/actions/workflows/get_pypi_stats.yml | ||
workflow_dispatch: | ||
|
||
jobs: | ||
# This workflow contains a single job called "pypi_stats" | ||
pypi_stats: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'icesat2py' | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: "traffic" | ||
|
||
# Calculates pypi stats and clones and stores in CSV file | ||
- name: Update pypi stats files | ||
run: | | ||
pip install -r requirements.txt | ||
python ./doc/source/tracking/pypistats/get_pypi_stats.py | ||
# Commits files to repository | ||
- name: Commit changes | ||
uses: EndBug/add-and-commit@v7 | ||
with: | ||
author_name: learn2phoenix | ||
message: "Pypi stats auto-update" | ||
add: "./doc/source/tracking/pypistats/*" | ||
# add: "./pypistats/*" | ||
branch: "traffic" # commits to branch "traffic" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
import pypistats | ||
import pandas as pd | ||
|
||
cwd = os.getcwd() | ||
|
||
trackpath = f'{cwd}/doc/source/tracking/pypistats/' | ||
downloadfn = "downloads_data.csv" | ||
sysdownloadfn = "sys_downloads_data.csv" | ||
|
||
downloads = pypistats.overall("icepyx", format="pandas").drop(columns=['percent']) | ||
downloads = downloads[downloads.category != "Total"] | ||
|
||
# try: | ||
exist_downloads = pd.read_csv(trackpath + downloadfn) # .drop(columns=['percent']) | ||
# exist_downloads = exist_downloads[exist_downloads.category != "Total"] | ||
dl_data = downloads.merge(exist_downloads, how='outer', | ||
on=['category', 'date', 'downloads']).reindex() | ||
# except: | ||
# dl_data = downloads | ||
|
||
dl_data.to_csv(trackpath + downloadfn, index=False) | ||
|
||
sysdownloads = pypistats.system("icepyx", format="pandas").drop(columns=['percent']) | ||
sysdownloads = sysdownloads[sysdownloads.category != "Total"] | ||
# try: | ||
exist_sysdownloads = pd.read_csv(trackpath + sysdownloadfn) # .drop(columns=['percent']) | ||
# exist_sysdownloads = exist_sysdownloads[exist_sysdownloads.category != "Total"] | ||
exist_sysdownloads['category'] = exist_sysdownloads['category'].fillna("null") | ||
sysdl_data = sysdownloads.merge(exist_sysdownloads, how='outer', | ||
on=['category', 'date', 'downloads']).reindex() | ||
# except: | ||
# dl_data = sysdownloads | ||
|
||
sysdl_data.to_csv(trackpath + sysdownloadfn, index=False) | ||
|
||
dl_data = dl_data.groupby("category").get_group("without_mirrors").sort_values("date") | ||
|
||
chart = dl_data.plot(x="date", y="downloads", figsize=(10, 2), | ||
label="Number of PyPI Downloads") | ||
chart.figure.savefig(trackpath + "downloads.svg") |