Spaces:
Running
Running
Preserve UTF-8 sandbox filenames in Lite runtime
Browse files- build_lite_runtime.py +45 -0
- index.html +1 -1
- lite_runtime.zip +2 -2
build_lite_runtime.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
import zipfile
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
ROOT = Path(__file__).resolve().parent
|
| 6 |
+
OUTPUT = ROOT / "lite_runtime.zip"
|
| 7 |
+
INPUTS = (ROOT / "eval_exp.py", ROOT / "chinatravel", ROOT / "leaderboard_data")
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def include(path: Path) -> bool:
|
| 11 |
+
relative = path.relative_to(ROOT)
|
| 12 |
+
if "__pycache__" in relative.parts or path.suffix in {".pyc", ".pyo"}:
|
| 13 |
+
return False
|
| 14 |
+
return not (path.name == "human1000.jsonl" and "oracle" in relative.parts)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def archive_files():
|
| 18 |
+
for source in INPUTS:
|
| 19 |
+
if source.is_file():
|
| 20 |
+
yield source
|
| 21 |
+
continue
|
| 22 |
+
yield from (path for path in sorted(source.rglob("*")) if path.is_file())
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
temporary = OUTPUT.with_suffix(".zip.tmp")
|
| 26 |
+
with zipfile.ZipFile(
|
| 27 |
+
temporary,
|
| 28 |
+
mode="w",
|
| 29 |
+
compression=zipfile.ZIP_DEFLATED,
|
| 30 |
+
compresslevel=9,
|
| 31 |
+
) as archive:
|
| 32 |
+
for path in archive_files():
|
| 33 |
+
if include(path):
|
| 34 |
+
archive.write(path, path.relative_to(ROOT).as_posix())
|
| 35 |
+
|
| 36 |
+
with zipfile.ZipFile(temporary) as archive:
|
| 37 |
+
names = archive.namelist()
|
| 38 |
+
private_oracles = [name for name in names if name.endswith("/human1000.jsonl")]
|
| 39 |
+
if private_oracles:
|
| 40 |
+
raise RuntimeError(f"Private Oracle files entered the Lite archive: {private_oracles}")
|
| 41 |
+
if "chinatravel/environment/database/intercity_transport/train/from_北京_to_上海.json" not in names:
|
| 42 |
+
raise RuntimeError("UTF-8 database filenames were not preserved in the Lite archive.")
|
| 43 |
+
|
| 44 |
+
temporary.replace(OUTPUT)
|
| 45 |
+
print(f"Wrote {OUTPUT} with {len(names)} files ({OUTPUT.stat().st_size} bytes).")
|
index.html
CHANGED
|
@@ -97,7 +97,7 @@ geopy>=2.4,<3
|
|
| 97 |
</gradio-requirements>
|
| 98 |
<gradio-file
|
| 99 |
name="lite_runtime.zip"
|
| 100 |
-
url="https://lamda-nesy-chinatravel.static.hf.space/lite_runtime.zip?v=
|
| 101 |
></gradio-file>
|
| 102 |
<gradio-file
|
| 103 |
name="lite_app.py"
|
|
|
|
| 97 |
</gradio-requirements>
|
| 98 |
<gradio-file
|
| 99 |
name="lite_runtime.zip"
|
| 100 |
+
url="https://lamda-nesy-chinatravel.static.hf.space/lite_runtime.zip?v=2"
|
| 101 |
></gradio-file>
|
| 102 |
<gradio-file
|
| 103 |
name="lite_app.py"
|
lite_runtime.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e762fe81cfd13c5e989633b137eadb6475884665b6a9368bae479f66bf248226
|
| 3 |
+
size 2185709
|