File size: 1,013 Bytes
2471af3
7505a51
 
 
2471af3
 
7505a51
 
 
 
 
 
 
 
 
 
 
 
 
 
2471af3
7505a51
2471af3
 
 
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
"""Fill raw/hubstats/ (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 folder is empty in the dataset (see
hfeco/hubstats.py); this is for refilling it by hand, 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 what was written to the dataset")
    a = ap.parse_args()
    paths = hubstats.backfill(org.history_ids(org.public_models()), a.every, a.since)
    if a.push and paths:
        store.push(paths, "hub-stats downloads history")
        print("pushed")


if __name__ == "__main__":
    main()