File size: 1,018 Bytes
7505a51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Write raw/hubstats.parquet (past downloads from cfahlgren1/hub-stats) by hand.

    python scripts/backfill_hubstats.py [--every 7] [--since 2025-01-01] [--push]

The daily job does this by itself when the file is missing from the dataset (see
hfeco/hubstats.py); this is for rebuilding it locally, e.g. with a different step.
"""
import argparse
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
from hfeco import hubstats, org, store  # noqa: E402


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--every", type=int, default=7)
    ap.add_argument("--since", default="2025-01-01")
    ap.add_argument("--push", action="store_true", help="upload raw/hubstats.parquet to the dataset")
    a = ap.parse_args()
    path = hubstats.backfill(org.history_ids(org.public_models()), a.every, a.since)
    if a.push:
        store.push([path], "hub-stats downloads history")
        print("pushed")


if __name__ == "__main__":
    main()