Skip to content

Commit

Permalink
Explicitly declare some schema fields as posix timestamps.
Browse files Browse the repository at this point in the history
This may yield clearer non-validation messages.
  • Loading branch information
vdbergh authored and ppigazzini committed Jul 3, 2024
1 parent f569e94 commit dbb8864
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions server/fishtest/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
sunumber = intersect(number, gt(0))

task_id = set_name(uint, "task_id")
timestamp = set_name(ufloat, "timestamp")


def size_is_length(x):
Expand Down Expand Up @@ -194,7 +195,7 @@ def action_is(x):
action_is("failed_task"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "failed_task",
"username": username,
"worker": long_worker_name,
Expand All @@ -208,7 +209,7 @@ def action_is(x):
action_is("crash_or_time"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "crash_or_time",
"username": username,
"worker": long_worker_name,
Expand All @@ -222,7 +223,7 @@ def action_is(x):
action_is("dead_task"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "dead_task",
"username": username,
"worker": long_worker_name,
Expand All @@ -235,7 +236,7 @@ def action_is(x):
action_is("system_event"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "system_event",
"username": "fishtest.system",
"message": action_message,
Expand All @@ -245,7 +246,7 @@ def action_is(x):
action_is("new_run"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "new_run",
"username": username,
"run_id": run_id,
Expand All @@ -257,7 +258,7 @@ def action_is(x):
action_is("upload_nn"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "upload_nn",
"username": username,
"nn": net_name,
Expand All @@ -267,7 +268,7 @@ def action_is(x):
action_is("modify_run"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "modify_run",
"username": username,
"run_id": run_id,
Expand All @@ -279,7 +280,7 @@ def action_is(x):
action_is("delete_run"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "delete_run",
"username": username,
"run_id": run_id,
Expand All @@ -291,7 +292,7 @@ def action_is(x):
intersect(
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "stop_run",
"username": username,
"run_id": run_id,
Expand All @@ -307,7 +308,7 @@ def action_is(x):
action_is("finished_run"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "finished_run",
"username": username,
"run_id": run_id,
Expand All @@ -319,7 +320,7 @@ def action_is(x):
action_is("approve_run"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "approve_run",
"username": username,
"run_id": run_id,
Expand All @@ -331,7 +332,7 @@ def action_is(x):
action_is("purge_run"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "purge_run",
"username": username,
"run_id": run_id,
Expand All @@ -343,7 +344,7 @@ def action_is(x):
action_is("block_user"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "block_user",
"username": username,
"user": str,
Expand All @@ -354,7 +355,7 @@ def action_is(x):
action_is("accept_user"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "accept_user",
"username": username,
"user": str,
Expand All @@ -365,7 +366,7 @@ def action_is(x):
action_is("block_worker"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "block_worker",
"username": username,
"worker": short_worker_name,
Expand All @@ -376,7 +377,7 @@ def action_is(x):
action_is("log_message"),
{
"_id?": ObjectId,
"time": float,
"time": timestamp,
"action": "log_message",
"username": username,
"message": action_message,
Expand Down Expand Up @@ -813,8 +814,8 @@ def flags_must_match(run):
run_id: {
"run": runs_schema,
"is_changed": bool, # Indicates if the run has changed since last_sync_time.
"last_sync_time": ufloat, # Last sync time (reading from or writing to db). If never synced then creation time.
"last_access_time": ufloat, # Last time the cache entry was touched (via buffer() or get_run()).
"last_sync_time": timestamp, # Last sync time (reading from or writing to db). If never synced then creation time.
"last_access_time": timestamp, # Last time the cache entry was touched (via buffer() or get_run()).
},
}

Expand All @@ -833,7 +834,7 @@ def flags_must_match(run):
active_runs_schema = {
"purge_count?": suint,
run_id: {
"time": ufloat,
"time": timestamp,
"lock": threading.RLock,
},
}
Expand Down

0 comments on commit dbb8864

Please sign in to comment.