File size: 1,263 Bytes
e2ce547 | 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | from __future__ import annotations
import getpass
import os
from pathlib import Path
from huggingface_hub import HfApi
PROJECT_DIR = Path(__file__).resolve().parents[1]
def main() -> None:
token = os.getenv("HF_TOKEN") or getpass.getpass("Hugging Face write token: ")
if not token.startswith("hf_"):
raise SystemExit("The token does not look like a Hugging Face token.")
api = HfApi(token=token)
namespace = api.whoami()["name"]
repo_id = f"{namespace}/polymarket-lp-collector-source"
api.create_repo(repo_id=repo_id, private=False, exist_ok=True)
api.upload_folder(
folder_path=PROJECT_DIR,
repo_id=repo_id,
ignore_patterns=[
".git/**",
".venv/**",
".venv-hf/**",
".tools/**",
"data/**",
"upload/**",
"**/__pycache__/**",
"*.zip",
".env",
".koyeb.yaml",
],
commit_message="Publish Render-ready Polymarket collector",
)
print(f"Source: https://huggingface.co/{repo_id}")
print(f"Git: https://huggingface.co/{repo_id}")
print(f"Dataset: https://huggingface.co/datasets/{namespace}/polymarket-l2-history")
if __name__ == "__main__":
main()
|