Spaces:
Running
Running
Download server/selfcheck.py from nsaroiu/mtg-deck-completion: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/nsaroiu/mtg-deck-completion/resolve/main/server/selfcheck.py
- Command line
-
hf download hf://spaces/nsaroiu/mtg-deck-completion/server/selfcheck.py
-
curl -L -o selfcheck.py https://huggingface.co/spaces/nsaroiu/mtg-deck-completion/resolve/main/server/selfcheck.py
1.23 kB
| """ | |
| 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() | |