Isaac Quarenta commited on
Commit ·
dccbaf4
1
Parent(s): 13413b9
fix(kaggle-cpu): resolver binario via nightly ggml-org (latest versionada nao tem assets)
Browse files- kaggle_backend.py +34 -9
kaggle_backend.py
CHANGED
|
@@ -82,21 +82,46 @@ def _llama_server_bin(workdir):
|
|
| 82 |
p = os.path.join(root, "llama-server")
|
| 83 |
os.chmod(p, os.stat(p).st_mode | stat.S_IEXEC)
|
| 84 |
return p
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
print("[kaggle-backend:cpu] a descobrir release llama.cpp ...", flush=True)
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
asset = None
|
| 94 |
-
for a in
|
| 95 |
if a.get("name", "").endswith("bin-ubuntu-x64.zip"):
|
| 96 |
asset = a
|
| 97 |
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
if asset is None:
|
| 99 |
-
raise RuntimeError("release sem bin-ubuntu-x64.zip")
|
| 100 |
zpath = os.path.join(workdir, asset["name"])
|
| 101 |
if not os.path.exists(zpath):
|
| 102 |
print(f"[kaggle-backend:cpu] a baixar {asset['name']} ...", flush=True)
|
|
|
|
| 82 |
p = os.path.join(root, "llama-server")
|
| 83 |
os.chmod(p, os.stat(p).st_mode | stat.S_IEXEC)
|
| 84 |
return p
|
| 85 |
+
import re as _re
|
| 86 |
+
|
| 87 |
+
def _gh_json(url):
|
| 88 |
+
req = urllib.request.Request(url, headers={"Accept": "application/vnd.github+json"})
|
| 89 |
+
_gh = os.getenv("GH_TOKEN", "").strip()
|
| 90 |
+
if _gh:
|
| 91 |
+
req.add_header("Authorization", f"Bearer {_gh}")
|
| 92 |
+
with urllib.request.urlopen(req, timeout=60) as r:
|
| 93 |
+
return _j.loads(r.read().decode())
|
| 94 |
+
|
| 95 |
+
# O repo mudou para ggml-org e as releases versionadas (v0.6.0 etc.)
|
| 96 |
+
# já NÃO trazem binários — só as nightlies (tags bNNNN). A latest
|
| 97 |
+
# indica a nightly no corpo ("Nightly build: [b11429](.../tag/b11429)").
|
| 98 |
print("[kaggle-backend:cpu] a descobrir release llama.cpp ...", flush=True)
|
| 99 |
+
rel = _gh_json("https://api.github.com/repos/ggml-org/llama.cpp/releases/latest")
|
| 100 |
+
assets = []
|
| 101 |
+
mtag = _re.search(r"releases/tag/(b\d+)", rel.get("body", "") or "")
|
| 102 |
+
if mtag:
|
| 103 |
+
try:
|
| 104 |
+
nrel = _gh_json(
|
| 105 |
+
"https://api.github.com/repos/ggml-org/llama.cpp/releases/tags/" + mtag.group(1))
|
| 106 |
+
assets = nrel.get("assets", [])
|
| 107 |
+
print(f"[kaggle-backend:cpu] nightly {mtag.group(1)}: {len(assets)} assets", flush=True)
|
| 108 |
+
except Exception as e:
|
| 109 |
+
print(f"[kaggle-backend:cpu] nightly falhou ({e}), a usar latest", flush=True)
|
| 110 |
+
if not assets:
|
| 111 |
+
assets = rel.get("assets", [])
|
| 112 |
asset = None
|
| 113 |
+
for a in assets:
|
| 114 |
if a.get("name", "").endswith("bin-ubuntu-x64.zip"):
|
| 115 |
asset = a
|
| 116 |
break
|
| 117 |
+
if asset is None: # fallback: qualquer zip ubuntu-x64
|
| 118 |
+
for a in assets:
|
| 119 |
+
nm = a.get("name", "")
|
| 120 |
+
if "ubuntu-x64" in nm and nm.endswith(".zip"):
|
| 121 |
+
asset = a
|
| 122 |
+
break
|
| 123 |
if asset is None:
|
| 124 |
+
raise RuntimeError("release sem bin-ubuntu-x64.zip (nem fallback ubuntu-x64)")
|
| 125 |
zpath = os.path.join(workdir, asset["name"])
|
| 126 |
if not os.path.exists(zpath):
|
| 127 |
print(f"[kaggle-backend:cpu] a baixar {asset['name']} ...", flush=True)
|