ummmar commited on
Commit
4740fdd
·
verified ·
1 Parent(s): ce2e318

Update sync_workspace.py

Browse files
Files changed (1) hide show
  1. sync_workspace.py +15 -9
sync_workspace.py CHANGED
@@ -1,18 +1,24 @@
1
  import os, time
2
- from huggingface_hub import HfApi, login
3
 
4
- # Use custom var to avoid HF's auto-injected read-only HF_TOKEN
5
  TOKEN = os.getenv("MY_HF_TOKEN")
6
- if not TOKEN:
7
- print("⏭️ Sync skipped: MY_HF_TOKEN not set.")
 
 
 
8
  exit(0)
9
 
10
- login(token=TOKEN)
11
- api = HfApi()
12
- WORKSPACE = "/workspace/projects"
13
- DATASET = os.getenv("HF_DATASET_REPO")
14
 
15
- api.create_repo(repo_id=DATASET, repo_type="dataset", private=True, exist_ok=True)
 
 
 
 
 
 
16
 
17
  IGNORES = [
18
  ".git", "node_modules", ".venv", "__pycache__", "dist", "build",
 
1
  import os, time
2
+ from huggingface_hub import HfApi
3
 
 
4
  TOKEN = os.getenv("MY_HF_TOKEN")
5
+ DATASET = os.getenv("HF_DATASET_REPO")
6
+ WORKSPACE = "/workspace/projects"
7
+
8
+ if not TOKEN or not DATASET:
9
+ print("⏭️ Sync skipped: MY_HF_TOKEN or HF_DATASET_REPO not set.")
10
  exit(0)
11
 
12
+ # Pass token directly to HfApi instead of using global login()
13
+ api = HfApi(token=TOKEN)
 
 
14
 
15
+ try:
16
+ api.create_repo(repo_id=DATASET, repo_type="dataset", private=True, exist_ok=True)
17
+ print(f"✅ Dataset {DATASET} verified/created.")
18
+ except Exception as e:
19
+ print(f"❌ Dataset access failed: {e}")
20
+ print(" Ensure MY_HF_TOKEN has WRITE permission and dataset name is correct.")
21
+ exit(0)
22
 
23
  IGNORES = [
24
  ".git", "node_modules", ".venv", "__pycache__", "dist", "build",