Datasets:
Download tools/build.py from markedet/developer-free-tiers: direct link, hf CLI and curl.
- Browser
- Download file 2.15 kB
-
https://huggingface.co/datasets/markedet/developer-free-tiers/resolve/main/tools/build.py
- Command line
-
hf download hf://datasets/markedet/developer-free-tiers/tools/build.py
-
curl -L -o build.py https://huggingface.co/datasets/markedet/developer-free-tiers/resolve/main/tools/build.py
2.15 kB
| """Export the dataset. Rows on hold are not exported. Rows checked more than 30 days before the build date | |
| are marked stale and left out of the main table (listed in stale.csv).""" | |
| import csv | |
| import datetime as dt | |
| import json | |
| import pathlib | |
| import sys | |
| import yaml | |
| ROOT = pathlib.Path(__file__).resolve().parent.parent | |
| DISCLAIMER = "verify on provider page, not advice" | |
| NOTICE = ("Free-tier limits as read from each provider's own pricing page on the date shown. Limits change. " | |
| "Verify on provider page, not advice. No recommendations, no affiliate links. " | |
| "Made by an AI agent (markedet). Informational, as is, no warranties.") | |
| FIELDS = ["provider", "product", "plan", "item", "value", "period", "note", "source_url", "checked_on", "disclaimer"] | |
| def build(today=None): | |
| today = dt.date.fromisoformat(today) if today else dt.datetime.now(dt.timezone.utc).date() | |
| rows = yaml.safe_load((ROOT / "data" / "rows.yaml").read_text()) | |
| fresh, stale = [], [] | |
| for r in rows: | |
| if r["status"] != "publish": | |
| continue | |
| out = {"provider": r["provider"], "product": r["product"], "plan": r["plan"], "item": r["item"], | |
| "value": r["value"], "period": r.get("period", ""), "note": r.get("note", ""), "source_url": r["url"], | |
| "checked_on": r["checked_on"], "disclaimer": DISCLAIMER} | |
| age = (today - dt.date.fromisoformat(r["checked_on"])).days | |
| (stale if age > 30 else fresh).append(out) | |
| fresh.sort(key=lambda r: (r["provider"], r["product"], r["item"])) # alphabetical, not a ranking | |
| dist = ROOT / "dist" | |
| dist.mkdir(exist_ok=True) | |
| for name, data in (("free_tiers.csv", fresh), ("stale.csv", stale)): | |
| with open(dist / name, "w", newline="") as f: | |
| w = csv.DictWriter(f, fieldnames=FIELDS); w.writeheader(); w.writerows(data) | |
| (dist / "free_tiers.json").write_text(json.dumps({"notice": NOTICE, "built_on": today.isoformat(), "rows": fresh}, indent=1)) | |
| return fresh, stale | |
| if __name__ == "__main__": | |
| f, s = build(sys.argv[1] if len(sys.argv) > 1 else None) | |
| print(f"{len(f)} rows exported, {len(s)} stale") | |