Skip to content

Commit

Permalink
Provide user_checks config knob to turn off user checks
Browse files Browse the repository at this point in the history
  • Loading branch information
George V. Kouryachy (Fr. Br. George) committed May 22, 2024
1 parent be29ac9 commit fe55741
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions hworker/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,8 @@ def need_screenreplay() -> bool:

def get_deadline_gap() -> datetime.time:
return config()["make"]["deadline_gap"]


def user_checks() -> bool:
"""Return False if user-defined checks are ignored."""
return config()["check"].get("user_checks", True)
1 change: 1 addition & 0 deletions hworker/config/default_hworker.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ deadline_gap = 03:00:00

[check]
directory = "/tmp/hworker_check"
user_checks = true

[formalization]
prog_name = "prog.py"
Expand Down
5 changes: 3 additions & 2 deletions hworker/make/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
get_task_info,
need_screenreplay,
get_deadline_gap,
user_checks,
)
from ..depot import store, search
from ..depot.objects import (
Expand Down Expand Up @@ -103,14 +104,14 @@ def get_solution(hw: Homework) -> Solution:
get_logger(__name__).warning(f"Incorrect remote content at {hw.ID} homework")

remote_checks = remote_content.get("remote", {})
own_checks = {check.ID: [] for check in get_checks(hw)}
own_checks = {check.ID: [] for check in get_checks(hw)} if user_checks() else {}
config_checks = get_task_info(hw.TASK_ID).get("checks", {})
solution_id = f"{hw.USER_ID}:{hw.TASK_ID}"

get_logger(__name__).debug(f"Extracted {solution_id} solution from {hw.ID} homework")
return Solution(
content=content,
checks=dict(own_checks, **remote_checks, **config_checks),
checks=own_checks | remote_checks | config_checks,
ID=solution_id,
TASK_ID=hw.TASK_ID,
USER_ID=hw.USER_ID,
Expand Down

0 comments on commit fe55741

Please sign in to comment.