feat: joj3 submission time check
All checks were successful
build / trigger-build-image (push) Successful in 15s
All checks were successful
build / trigger-build-image (push) Successful in 15s
This commit is contained in:
parent
2c1123892c
commit
bbc415b33d
|
@ -4,7 +4,7 @@ import re
|
|||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from time import sleep
|
||||
from typing import TYPE_CHECKING, List
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
# from filelock import FileLock
|
||||
from git import Repo
|
||||
|
@ -446,6 +446,8 @@ def joj3_check_env(
|
|||
"Example: --group-config joj=10:24,run=20:48"
|
||||
),
|
||||
),
|
||||
valid_after: Optional[datetime] = Option(None),
|
||||
valid_before: Optional[datetime] = Option(None),
|
||||
) -> None:
|
||||
app.pretty_exceptions_enable = False
|
||||
set_settings(Settings(_env_file=env_path))
|
||||
|
@ -458,10 +460,21 @@ def joj3_check_env(
|
|||
):
|
||||
logger.error("missing required env var")
|
||||
raise Exit(code=1)
|
||||
msg, failed = tea.pot.joj3_check_submission_count(
|
||||
time_msg, time_failed = tea.pot.joj3_check_submission_time(
|
||||
valid_after,
|
||||
valid_before,
|
||||
)
|
||||
count_msg, count_failed = tea.pot.joj3_check_submission_count(
|
||||
env, grading_repo_name, group_config, scoreboard_filename
|
||||
)
|
||||
echo(json.dumps({"msg": msg, "failed": failed})) # print result to stdout for joj3
|
||||
echo(
|
||||
json.dumps(
|
||||
{
|
||||
"msg": time_msg + count_msg,
|
||||
"failed": time_failed or count_failed,
|
||||
}
|
||||
)
|
||||
) # print result to stdout for joj3
|
||||
logger.info("joj3-check-env done")
|
||||
|
||||
|
||||
|
|
|
@ -281,6 +281,26 @@ class Teapot:
|
|||
)
|
||||
return joj3_issue.number
|
||||
|
||||
def joj3_check_submission_time(
|
||||
self,
|
||||
valid_after: Optional[datetime] = None,
|
||||
valid_before: Optional[datetime] = None,
|
||||
) -> Tuple[str, bool]:
|
||||
now = datetime.now()
|
||||
if (valid_after and now < valid_after) or (valid_before and now > valid_before):
|
||||
return (
|
||||
"### Submission Time Check Failed:\n"
|
||||
f"Current time {now} is not in the valid range.\n"
|
||||
f"After: {valid_after}, Before: {valid_before}\n",
|
||||
True,
|
||||
)
|
||||
return (
|
||||
"### Submission Time Check Passed:\n"
|
||||
f"Current time {now} is in the valid range.\n"
|
||||
f"After: {valid_after}, Before: {valid_before}\n",
|
||||
False,
|
||||
)
|
||||
|
||||
def joj3_check_submission_count(
|
||||
self,
|
||||
env: joj3.Env,
|
||||
|
|
Loading…
Reference in New Issue
Block a user