Compare commits

..

No commits in common. "bbd01329ed6538718051db0de93d733ebecf04b0" and "dea58d179ebde56b5b491f8e10b26b598df93840" have entirely different histories.

2 changed files with 5 additions and 40 deletions

View File

@ -4,7 +4,7 @@ import re
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from time import sleep from time import sleep
from typing import TYPE_CHECKING, List, Optional from typing import TYPE_CHECKING, List
# from filelock import FileLock # from filelock import FileLock
from git import Repo from git import Repo
@ -450,8 +450,6 @@ def joj3_check_env(
"Example: --group-config joj=10:24,run=20:48" "Example: --group-config joj=10:24,run=20:48"
), ),
), ),
valid_after: Optional[datetime] = Option(None),
valid_before: Optional[datetime] = Option(None),
) -> None: ) -> None:
app.pretty_exceptions_enable = False app.pretty_exceptions_enable = False
set_settings(Settings(_env_file=env_path)) set_settings(Settings(_env_file=env_path))
@ -464,21 +462,10 @@ def joj3_check_env(
): ):
logger.error("missing required env var") logger.error("missing required env var")
raise Exit(code=1) raise Exit(code=1)
time_msg, time_failed = tea.pot.joj3_check_submission_time( msg, failed = tea.pot.joj3_check_submission_count(
valid_after,
valid_before,
)
count_msg, count_failed = tea.pot.joj3_check_submission_count(
env, grading_repo_name, group_config, scoreboard_filename env, grading_repo_name, group_config, scoreboard_filename
) )
echo( echo(json.dumps({"msg": msg, "failed": failed})) # print result to stdout for joj3
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") logger.info("joj3-check-env done")

View File

@ -282,26 +282,6 @@ class Teapot:
) )
return joj3_issue.number 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 "
f"[{valid_after}, {valid_before}].\n",
True,
)
return (
"### Submission Time Check Passed:\n"
f"Current time {now} is in the valid range "
f"[{valid_after}, {valid_before}].\n",
False,
)
def joj3_check_submission_count( def joj3_check_submission_count(
self, self,
env: joj3.Env, env: joj3.Env,
@ -384,15 +364,13 @@ class Teapot:
comment += f"keyword `{name}` " comment += f"keyword `{name}` "
use_group = name.lower() in env.joj3_groups.lower() use_group = name.lower() in env.joj3_groups.lower()
comment += ( comment += (
f"In last {time_period} hour(s): " f"in last {time_period} hour(s): "
f"submit count {submit_count}, " f"submit count {submit_count}, "
f"max count {max_count}" f"max count {max_count}"
) )
if use_group and submit_count + 1 > max_count: if use_group and submit_count + 1 > max_count:
failed = True failed = True
comment += ", exceeded." comment += ", exceeded"
else:
comment += "."
comment += "\n" comment += "\n"
if failed: if failed:
title = "### Submission Count Check Failed:" title = "### Submission Count Check Failed:"