Spaces:
Running on Zero
Running on Zero
File size: 850 Bytes
77105ca ebc3bf5 77105ca ebc3bf5 77105ca ebc3bf5 77105ca ebc3bf5 77105ca ebc3bf5 77105ca ebc3bf5 77105ca | 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 | def make_store() -> list:
return []
def save_run(store: list, record: dict) -> tuple[int, list]:
run_id = store[-1]["id"] + 1 if store else 1
return run_id, store + [{"id": run_id, **record}]
def get_runs(store: list, limit: int = 100) -> list[dict]:
return list(reversed(store))[:limit]
def get_run(store: list, run_id: int) -> dict | None:
return next((r for r in store if r["id"] == run_id), None)
def delete_run(store: list, run_id: int) -> list:
return [r for r in store if r["id"] != run_id]
def update_feedback(store: list, run_id: int, value: int) -> list:
return [{**r, "feedback": value} if r["id"] == run_id else r for r in store]
def update_feedback_comment(store: list, run_id: int, comment: str) -> list:
return [{**r, "feedback_comment": comment} if r["id"] == run_id else r for r in store]
|