Spaces:
Sleeping
Sleeping
Upload scripts/push_to_hf_space.py with huggingface_hub
Browse files
scripts/push_to_hf_space.py
CHANGED
|
@@ -17,7 +17,9 @@ from huggingface_hub.errors import HfHubHTTPError
|
|
| 17 |
|
| 18 |
def main():
|
| 19 |
repo_id = os.environ.get("HF_SPACE_REPO_ID") or os.environ.get("HF_SPACE_REPO") or "Dyra1204/BiasGuard-Pro"
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Auth: prefer explicit env var, otherwise use cached token from `hf auth login`.
|
| 23 |
token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
|
|
@@ -52,9 +54,11 @@ def main():
|
|
| 52 |
# Walk repository and upload files (skip ignored directories)
|
| 53 |
to_upload = []
|
| 54 |
for root, dirs, files in os.walk("."):
|
| 55 |
-
# mutate dirs in-place to skip unwanted
|
| 56 |
-
dirs[:] = [d for d in dirs if d not in skip_dirs
|
| 57 |
for fn in files:
|
|
|
|
|
|
|
| 58 |
if fn.endswith((".pyc", ".pyo", ".log")):
|
| 59 |
continue
|
| 60 |
# skip hidden cache files in repo root
|
|
|
|
| 17 |
|
| 18 |
def main():
|
| 19 |
repo_id = os.environ.get("HF_SPACE_REPO_ID") or os.environ.get("HF_SPACE_REPO") or "Dyra1204/BiasGuard-Pro"
|
| 20 |
+
# User-requested: push everything except venv + pytest cache.
|
| 21 |
+
# We also skip a few always-unwanted runtime folders.
|
| 22 |
+
skip_dirs = {".venv", ".pytest_cache", ".git", "__pycache__", ".cache"}
|
| 23 |
|
| 24 |
# Auth: prefer explicit env var, otherwise use cached token from `hf auth login`.
|
| 25 |
token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
|
|
|
|
| 54 |
# Walk repository and upload files (skip ignored directories)
|
| 55 |
to_upload = []
|
| 56 |
for root, dirs, files in os.walk("."):
|
| 57 |
+
# mutate dirs in-place to skip unwanted directories
|
| 58 |
+
dirs[:] = [d for d in dirs if d not in skip_dirs]
|
| 59 |
for fn in files:
|
| 60 |
+
if fn == ".DS_Store":
|
| 61 |
+
continue
|
| 62 |
if fn.endswith((".pyc", ".pyo", ".log")):
|
| 63 |
continue
|
| 64 |
# skip hidden cache files in repo root
|