Skip to content

Commit

Permalink
feat: system per slot
Browse files Browse the repository at this point in the history
  • Loading branch information
wozeparrot committed Apr 30, 2024
1 parent 8fea613 commit 1dff76c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tinymod/stats/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging, json, ssl, os

from common.helpers import getenv
from common.benchmarks import CachedBenchmarks
from common.benchmarks import CachedBenchmarks, ALL_SYSTEMS

API_INVALID_ARGUMENT = json.dumps({"error": "Invalid argument."})
API_INVALID_COMMAND = json.dumps({"error": "Invalid command."})
Expand Down Expand Up @@ -40,8 +40,10 @@ async def handler(self, protocol):
await protocol.send(API_INVALID_ARGUMENT)
continue
logging.info(f"{protocol.remote_address} requested benchmarks for {filename} on {system} for last {last_n}.")
benchmarks = CachedBenchmarks.cache.get((filename, system), [])[-last_n:]
benchmarks = [{"x": x, "y": y} for x, y in benchmarks]
benchmarks = [[], [], [], []]
systems = system.split("_")
for system_ in systems: benchmarks[ALL_SYSTEMS.index(system_)] = CachedBenchmarks.cache.get((filename, system_), [])[-last_n:]
benchmarks = [[{"x": x, "y": y} for x,y in benchmark] for benchmark in benchmarks]
await protocol.send(json.dumps({"filename": filename, "system": system, "benchmarks": benchmarks}))
case "get-commit":
await protocol.send(json.dumps({"commit": CachedBenchmarks.curr_commit}))
Expand Down

0 comments on commit 1dff76c

Please sign in to comment.