Dyra1204 commited on
Commit
b11ccc9
·
verified ·
1 Parent(s): cdd3fb5

Upload scripts/push_to_hf_space.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/push_to_hf_space.py +5 -4
scripts/push_to_hf_space.py CHANGED
@@ -17,7 +17,7 @@ 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
- skip_dirs = {"models", "results", ".git", "__pycache__", ".venv", ".cache"}
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,14 +52,15 @@ 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 directories
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
61
  rel_dir = os.path.relpath(root, ".")
62
- if rel_dir.startswith("."):
 
63
  rel_dir = ""
64
  local_path = os.path.join(root, fn)
65
  # avoid uploading the uploader script itself twice when executed from repo
 
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
+ skip_dirs = {"models", "results", ".git", "__pycache__", ".venv", ".cache", ".pytest_cache"}
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
  # 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 and hidden directories
56
+ dirs[:] = [d for d in dirs if d not in skip_dirs and not d.startswith(".")]
57
  for fn in files:
58
  if fn.endswith((".pyc", ".pyo", ".log")):
59
  continue
60
  # skip hidden cache files in repo root
61
  rel_dir = os.path.relpath(root, ".")
62
+ # only collapse the actual repo root (".") to empty string; keep real subdirs
63
+ if rel_dir == ".":
64
  rel_dir = ""
65
  local_path = os.path.join(root, fn)
66
  # avoid uploading the uploader script itself twice when executed from repo