Download code/scripts/push_code.py from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/d7eb238c7e68d5d4ddeaffe289e2e44323a98bd8/code/scripts/push_code.py
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@d7eb238c7e68d5d4ddeaffe289e2e44323a98bd8/code/scripts/push_code.py
-
curl -L -o push_code.py https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/d7eb238c7e68d5d4ddeaffe289e2e44323a98bd8/code/scripts/push_code.py
1.21 kB
| """Upload the pipeline code to the dataset repo's code/ folder (the daily HF Job runs from there). | |
| python scripts/push_code.py | |
| Uploads every git-tracked file outside web/ and eval/, so a new module can't be forgotten. | |
| """ | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(ROOT)) | |
| from huggingface_hub import CommitOperationAdd, CommitOperationDelete # noqa: E402 | |
| from hfeco.hub import api # noqa: E402 | |
| from hfeco.store import DATASET_REPO # noqa: E402 | |
| files = subprocess.run(["git", "ls-files"], cwd=ROOT, capture_output=True, text=True, check=True).stdout.split() | |
| files = [f for f in files if not f.startswith(("web/", "eval/", "space/"))] | |
| remote = {f[len("code/"):] for f in api.list_repo_files(DATASET_REPO, repo_type="dataset") if f.startswith("code/")} | |
| ops = [CommitOperationAdd(path_in_repo=f"code/{f}", path_or_fileobj=str(ROOT / f)) for f in files] | |
| ops += [CommitOperationDelete(path_in_repo=f"code/{f}") for f in sorted(remote - set(files))] | |
| api.create_commit(DATASET_REPO, ops, repo_type="dataset", commit_message="code: sync from git") | |
| print(f"code/: {len(files)} files uploaded, {len(remote - set(files))} removed") | |