Spaces:
Sleeping
Sleeping
File size: 1,232 Bytes
8538f10 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | """
selfcheck.py
Loads the installed model the way the server does and builds one deck.
The Docker build runs it right after installing the model files, so a
release this code can't load (a changed architecture, a newer tokenizer
format) fails the build instead of producing an image that crashes on
startup. Exits non-zero on any failure:
python -m server.selfcheck
"""
from __future__ import annotations
import time
COMMANDER = "Meren of Clan Nel Toth"
DECKLIST = "1 Sol Ring\n1 Sakura-Tribe Elder\n4 Swamp"
def main() -> None:
from server.deckbuilder import DeckBuilder
from server.model_files import read_version
start = time.perf_counter()
builder = DeckBuilder(read_version())
loaded = time.perf_counter()
completion = builder.complete([COMMANDER], DECKLIST)
total = completion.to_dict()["summary"]["total"]
if total != 100:
raise SystemExit(f"Selfcheck failed: built a {total}-card deck for {COMMANDER}, expected 100.")
sha = (builder.version or {}).get("sha", "unknown")[:7]
print(f"Selfcheck passed: model {sha} loaded in {loaded - start:.1f}s, "
f"built a 100-card deck in {time.perf_counter() - loaded:.1f}s.")
if __name__ == "__main__":
main()
|