ummmar commited on
Commit
ce2e318
·
verified ·
1 Parent(s): 92ba885

Update restore_workspace.py

Browse files
Files changed (1) hide show
  1. restore_workspace.py +9 -3
restore_workspace.py CHANGED
@@ -1,15 +1,21 @@
1
  import os, shutil
2
  from huggingface_hub import snapshot_download
3
 
4
- HF_TOKEN = os.getenv("HF_TOKEN")
 
5
  DATASET = os.getenv("HF_DATASET_REPO")
6
  WORKSPACE = "/workspace/projects"
7
 
 
 
 
 
 
8
  try:
9
  print("⬇️ Restoring workspace from HF Dataset...")
10
  snapshot_download(
11
- repo_id=DATASET, repo_type="dataset",
12
- local_dir="/tmp/ws_restore", token=HF_TOKEN,
13
  ignore_patterns=[".git", "__pycache__"]
14
  )
15
  if os.path.exists(WORKSPACE):
 
1
  import os, shutil
2
  from huggingface_hub import snapshot_download
3
 
4
+ # Use custom var to avoid HF's auto-injected read-only HF_TOKEN
5
+ TOKEN = os.getenv("MY_HF_TOKEN")
6
  DATASET = os.getenv("HF_DATASET_REPO")
7
  WORKSPACE = "/workspace/projects"
8
 
9
+ if not TOKEN:
10
+ print("⏭️ Restore skipped: MY_HF_TOKEN not set.")
11
+ os.makedirs(WORKSPACE, exist_ok=True)
12
+ exit(0)
13
+
14
  try:
15
  print("⬇️ Restoring workspace from HF Dataset...")
16
  snapshot_download(
17
+ repo_id=DATASET, repo_type="dataset",
18
+ local_dir="/tmp/ws_restore", token=TOKEN,
19
  ignore_patterns=[".git", "__pycache__"]
20
  )
21
  if os.path.exists(WORKSPACE):