danielrosehill
commited on
Commit
·
a05037b
1
Parent(s):
f2d7c8e
updated
Browse files- .github/scripts/update_stats.py +24 -0
- .github/workflows/update_downloads.yml +24 -0
- README.md +8 -0
.github/scripts/update_stats.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import csv
|
3 |
+
from datetime import datetime
|
4 |
+
|
5 |
+
API_URL = "https://huggingface.co/api/datasets/danielrosehill/ifvi_valuefactors_deriv?expand[]=downloads&expand[]=downloadsAllTime"
|
6 |
+
response = requests.get(API_URL)
|
7 |
+
data = response.json()
|
8 |
+
downloads = data.get('downloads', 0)
|
9 |
+
today = datetime.now().strftime('%Y-%m-%d')
|
10 |
+
|
11 |
+
try:
|
12 |
+
with open('daily_downloads.csv', mode='r') as file:
|
13 |
+
reader = csv.reader(file)
|
14 |
+
rows = list(reader)
|
15 |
+
except FileNotFoundError:
|
16 |
+
rows = []
|
17 |
+
|
18 |
+
with open('daily_downloads.csv', mode='w', newline='') as file:
|
19 |
+
writer = csv.writer(file)
|
20 |
+
if not rows:
|
21 |
+
writer.writerow(["Date", "Total Downloads"])
|
22 |
+
else:
|
23 |
+
writer.writerows(rows)
|
24 |
+
writer.writerow([today, downloads])
|
.github/workflows/update_downloads.yml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Update Download Stats
|
2 |
+
on:
|
3 |
+
schedule:
|
4 |
+
- cron: '0 0 * * *'
|
5 |
+
workflow_dispatch:
|
6 |
+
|
7 |
+
jobs:
|
8 |
+
update-stats:
|
9 |
+
runs-on: ubuntu-latest
|
10 |
+
steps:
|
11 |
+
- uses: actions/checkout@v3
|
12 |
+
- uses: actions/setup-python@v3
|
13 |
+
with:
|
14 |
+
python-version: '3.x'
|
15 |
+
- run: pip install requests
|
16 |
+
- name: Update stats
|
17 |
+
run: python .github/scripts/update_stats.py
|
18 |
+
- name: Commit changes
|
19 |
+
run: |
|
20 |
+
git config --local user.email "[email protected]"
|
21 |
+
git config --local user.name "GitHub Action"
|
22 |
+
git add daily_downloads.csv
|
23 |
+
git commit -m "Update download stats" || exit 0
|
24 |
+
git push
|
README.md
CHANGED
@@ -32,6 +32,14 @@ The GVFD covers 430 different environmental impacts across four main categories
|
|
32 |
|
33 |
---
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
# Impact Categories In Dataset
|
36 |
|
37 |
![alt text](images/graphics/4.png)
|
|
|
32 |
|
33 |
---
|
34 |
|
35 |
+
## Download Statistics
|
36 |
+
|
37 |
+
graph TD
|
38 |
+
subgraph Downloads
|
39 |
+
end
|
40 |
+
|
41 |
+
---
|
42 |
+
|
43 |
# Impact Categories In Dataset
|
44 |
|
45 |
![alt text](images/graphics/4.png)
|