Skip to content

Commit

Permalink
style: fix style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanker committed Jan 31, 2024
1 parent b5d16ac commit 639ba42
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 83 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/get_pypi_stats.yml
Expand Up @@ -18,23 +18,23 @@ jobs:

# 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@v3
with:
ref: "traffic"
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
ref: "traffic"

# Calculates pypi stats and clones and stores in CSV file
- name: Update pypi stats files
run: |
pip install -U pip
pip install pypistats pandas seaborn matplotlib
python ./docs/tracking/stats.py
# Calculates pypi stats and clones and stores in CSV file
- name: Update pypi stats files
run: |
pip install -U pip
pip install pypistats pandas seaborn matplotlib
python ./docs/tracking/stats.py
# Commits files to repository
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
author_name: pypistats
message: "Pypi stats auto-update"
add: "./docs/tracking/*"
# add: "./pypistats/*"
# Commits files to repository
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
author_name: pypistats
message: "Pypi stats auto-update"
add: "./docs/tracking/*"
# add: "./pypistats/*"
Binary file modified docs/tracking/downloads.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 52 additions & 48 deletions docs/tracking/gather-targeted-package-metrics.ipynb
Expand Up @@ -22,6 +22,7 @@
"outputs": [],
"source": [
"import json\n",
"\n",
"import pandas as pd"
]
},
Expand All @@ -48,7 +49,7 @@
"loi_target_projects = [\n",
" # \"antarctic_plots\",\n",
" \"polartoolkit\",\n",
" ]\n",
"]\n",
"loi_target_projects"
]
},
Expand Down Expand Up @@ -106,10 +107,7 @@
}
],
"source": [
"df = pd.DataFrame(\n",
" data={\n",
" \"project\": [\"polartoolkit\"],\n",
" \"date\": [\"2021-01-01\"]})\n",
"df = pd.DataFrame(data={\"project\": [\"polartoolkit\"], \"date\": [\"2021-01-01\"]})\n",
"df[\"date\"] = pd.to_datetime(df.date)\n",
"df"
]
Expand Down Expand Up @@ -145,19 +143,21 @@
],
"source": [
"# gather total downloads\n",
"total_downloads = json.loads(subprocess.run(\n",
" [\n",
" \"pypinfo\",\n",
" \"--json\",\n",
" \"--start-date\",\n",
" start_date,\n",
" \"--limit\",\n",
" \"1000\",\n",
" project,\n",
" ],\n",
" capture_output=True,\n",
" check=True,\n",
").stdout)[\"rows\"][0][\"download_count\"]\n",
"total_downloads = json.loads(\n",
" subprocess.run(\n",
" [\n",
" \"pypinfo\",\n",
" \"--json\",\n",
" \"--start-date\",\n",
" start_date,\n",
" \"--limit\",\n",
" \"1000\",\n",
" project,\n",
" ],\n",
" capture_output=True,\n",
" check=True,\n",
" ).stdout\n",
")[\"rows\"][0][\"download_count\"]\n",
"\n",
"total_downloads"
]
Expand Down Expand Up @@ -323,22 +323,24 @@
],
"source": [
"# gather downloads by year and month, ordered by month\n",
"output = json.loads(subprocess.run(\n",
" [\n",
" \"pypinfo\",\n",
" \"--json\",\n",
" \"--start-date\",\n",
" start_date,\n",
" \"--limit\",\n",
" \"1000\",\n",
" \"--order\",\n",
" \"download_month\",\n",
" project,\n",
" \"month\",\n",
" ],\n",
" capture_output=True,\n",
" check=True,\n",
").stdout)\n",
"output = json.loads(\n",
" subprocess.run(\n",
" [\n",
" \"pypinfo\",\n",
" \"--json\",\n",
" \"--start-date\",\n",
" start_date,\n",
" \"--limit\",\n",
" \"1000\",\n",
" \"--order\",\n",
" \"download_month\",\n",
" project,\n",
" \"month\",\n",
" ],\n",
" capture_output=True,\n",
" check=True,\n",
" ).stdout\n",
")\n",
"\n",
"monthly_downloads = pd.DataFrame(output[\"rows\"])\n",
"monthly_downloads"
Expand Down Expand Up @@ -577,20 +579,22 @@
],
"source": [
"# gather downloads by country\n",
"output = json.loads(subprocess.run(\n",
" [\n",
" \"pypinfo\",\n",
" \"--json\",\n",
" \"--start-date\",\n",
" start_date,\n",
" \"--limit\",\n",
" \"1000\",\n",
" project,\n",
" \"country\",\n",
" ],\n",
" capture_output=True,\n",
" check=True,\n",
").stdout)\n",
"output = json.loads(\n",
" subprocess.run(\n",
" [\n",
" \"pypinfo\",\n",
" \"--json\",\n",
" \"--start-date\",\n",
" start_date,\n",
" \"--limit\",\n",
" \"1000\",\n",
" project,\n",
" \"country\",\n",
" ],\n",
" capture_output=True,\n",
" check=True,\n",
" ).stdout\n",
")\n",
"\n",
"country_downloads = pd.DataFrame(output[\"rows\"])\n",
"country_downloads"
Expand Down
31 changes: 17 additions & 14 deletions docs/tracking/stats.py
Expand Up @@ -14,28 +14,28 @@
https://github.com/icesat2py/icepyx/blob/6c187bd35358d88083a5163d3491118aa1aad45c/doc/source/tracking/pypistats/get_pypi_stats.py
"""

import os
import pypistats
import pathlib

import matplotlib.pyplot as plt
import pandas as pd
import pypistats
import seaborn as sns
import matplotlib.pyplot as plt

sns.set_theme()

cwd = os.getcwd()
cwd = pathlib.Path.cwd()

trackpath = f"{cwd}/docs/tracking/"
downloadfn = "downloads_data.csv"
sysdownloadfn = "sys_downloads_data.csv"

antarctic_plots_downloads = pypistats.overall(
"antarctic_plots",
total=True,
format="pandas").drop(columns=["percent"])
"antarctic_plots", total=True, format="pandas"
).drop(columns=["percent"])

polartoolkit_downloads = pypistats.overall(
"polartoolkit",
total=True,
format="pandas").drop(columns=["percent"])
"polartoolkit", total=True, format="pandas"
).drop(columns=["percent"])

downloads = pd.concat([antarctic_plots_downloads, polartoolkit_downloads])

Expand All @@ -47,7 +47,7 @@
dl_data = downloads.merge(
exist_downloads, how="outer", on=["category", "date", "downloads"]
)
except:
except NameError:
dl_data = downloads

total_downloads = dl_data.downloads.sum()
Expand Down Expand Up @@ -76,7 +76,10 @@


chart = dl_data.plot(
x="date", y="downloads", figsize=(10, 2), legend=False,
x="date",
y="downloads",
figsize=(10, 2),
legend=False,
)

chart.set_ylabel("Downloads")
Expand All @@ -87,7 +90,7 @@
)

chart.text(
0,1, f"{total_downloads} total downloads",
va="top", transform=plt.gca().transAxes)
0, 1, f"{total_downloads} total downloads", va="top", transform=plt.gca().transAxes
)

chart.figure.savefig(trackpath + "downloads.png")
9 changes: 6 additions & 3 deletions docs/tracking/usage_stats.md
@@ -1,12 +1,15 @@
## PyPI Downloads

Non-mirrored downloads of polartoolkit from the `Python Package Index <https://pypi.org/>`_ (e.g. using `pip install polartoolkit`).
Non-mirrored downloads of polartoolkit from the
`Python Package Index <https://pypi.org/>`\_ (e.g. using
`pip install polartoolkit`).

![Download stats](downloads.png)

## GitHub Traffic
The GitHub repository has automatic tracking of cloning and traffic to the repo website, which can be found [here](https://github.com/mdtanker/polartoolkit/graphs/traffic).

The GitHub repository has automatic tracking of cloning and traffic to the repo
website, which can be found
[here](https://github.com/mdtanker/polartoolkit/graphs/traffic).

## Documentation Views

0 comments on commit 639ba42

Please sign in to comment.