ThongCoder commited on
Commit
425fb71
·
verified ·
1 Parent(s): 8cee880

Delete restore.py

Browse files
Files changed (1) hide show
  1. restore.py +0 -45
restore.py DELETED
@@ -1,45 +0,0 @@
1
- import os, subprocess
2
-
3
- def restore_workspace():
4
- repo_id = os.environ.get("BACKUP_REPO")
5
- hf_token = os.environ.get("HF_TOKEN")
6
- repo_type = "dataset"
7
-
8
- if not repo_id or not hf_token:
9
- print("❌ BACKUP_REPO or HF_TOKEN missing, skipping restore")
10
- return
11
-
12
- env = os.environ.copy()
13
- env["HF_HOME"] = "/tmp/hf_cache"
14
- env["XDG_CACHE_HOME"] = "/tmp/xdg_cache"
15
- env["TMPDIR"] = "/tmp"
16
-
17
- os.makedirs(env["HF_HOME"], exist_ok=True)
18
- os.makedirs(env["XDG_CACHE_HOME"], exist_ok=True)
19
- os.makedirs(env["TMPDIR"], exist_ok=True)
20
-
21
- local_path = "/workspace"
22
- os.makedirs(local_path, exist_ok=True)
23
-
24
- cmd = [
25
- "hf", "download",
26
- repo_id,
27
- "--repo-type", repo_type,
28
- "--token", hf_token,
29
- "--local-dir", local_path,
30
- ]
31
-
32
- print("🔄 Restoring workspace from backup...")
33
- process = subprocess.Popen(
34
- cmd,
35
- stdout=subprocess.PIPE,
36
- stderr=subprocess.STDOUT,
37
- env=env,
38
- text=True,
39
- cwd="/tmp",
40
- )
41
-
42
- for line in iter(process.stdout.readline, ''):
43
- print("📥", line.strip())
44
-
45
- print("✅ Restore complete.")