Skip to content

Commit

Permalink
Merge branch 'development' into cmr-scrolling-search
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaS11 authored Feb 4, 2022
2 parents 4c8e379 + a9c7813 commit 02481ae
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 124 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/get_pypi_stats.yml
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"
124 changes: 0 additions & 124 deletions doc/source/tracking/pypistats/get_pypi_stats.ipynb

This file was deleted.

41 changes: 41 additions & 0 deletions doc/source/tracking/pypistats/get_pypi_stats.py
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")

0 comments on commit 02481ae

Please sign in to comment.