Update misc.py
Browse files
misc.py
CHANGED
|
@@ -48,27 +48,35 @@ def log_pair(pair):
|
|
| 48 |
with open('public/pair.txt', 'at+') as f:
|
| 49 |
f.write(pair + '\n')
|
| 50 |
|
| 51 |
-
def trigger_push(
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
"Authorization": f"Bearer {token}",
|
| 60 |
-
"User-Agent": "hf-dataset-pusher",
|
| 61 |
-
"X-GitHub-Api-Version": "2022-11-28"
|
| 62 |
-
}
|
| 63 |
-
data = {"ref": "main",
|
| 64 |
-
"inputs": {
|
| 65 |
-
"base_url": "https://thongcoder-infinite-craft-searcher.hf.space",
|
| 66 |
-
"amount": amount
|
| 67 |
-
}
|
| 68 |
-
}
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
with open('public/pair.txt', 'at+') as f:
|
| 49 |
f.write(pair + '\n')
|
| 50 |
|
| 51 |
+
def trigger_push(n):
|
| 52 |
+
env["HF_HOME"] = "/tmp/hf_cache"
|
| 53 |
+
env["XDG_CACHE_HOME"] = "/tmp/xdg_cache"
|
| 54 |
+
env["TMPDIR"] = "/tmp"
|
| 55 |
|
| 56 |
+
os.makedirs(env["HF_HOME"], exist_ok=True)
|
| 57 |
+
os.makedirs(env["XDG_CACHE_HOME"], exist_ok=True)
|
| 58 |
+
os.makedirs(env["TMPDIR"], exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
cwd = "/tmp"
|
| 61 |
+
os.makedirs(cwd, exist_ok=True)
|
| 62 |
+
|
| 63 |
+
repo_id = 'ThongCoder/infinite-craft'
|
| 64 |
+
local_path = 'db/cache.sqlite'
|
| 65 |
+
path_in_repo = 'cache.sqlite'
|
| 66 |
+
repo_type = 'dataset'
|
| 67 |
+
|
| 68 |
+
cmd = [
|
| 69 |
+
"hf", "upload",
|
| 70 |
+
repo_id,
|
| 71 |
+
local_path,
|
| 72 |
+
path_in_repo,
|
| 73 |
+
"--repo-type", repo_type,
|
| 74 |
+
]
|
| 75 |
+
|
| 76 |
+
process = subprocess.Popen(
|
| 77 |
+
cmd,
|
| 78 |
+
env=env,
|
| 79 |
+
text=True,
|
| 80 |
+
cwd=cwd,
|
| 81 |
+
)
|
| 82 |
+
process.wait()
|