Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix merge ignore processing, add tests, move store from check functions to make #65

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move store from check functions to make
  • Loading branch information
Nikita-Barabanov committed Aug 25, 2023
commit 78851a90119a913d7a9d9dbd6c3abff80567ab69
12 changes: 6 additions & 6 deletions hworker/check/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Universal check function"""

from .runtime import runtime
from .validate import validate
from ..depot.objects import Check, Solution, CheckCategoryEnum
from .runtime import runtime_wo_store
from .validate import validate_wo_store
from ..depot.objects import Check, Solution, CheckCategoryEnum, CheckResult


def check(checker: Check, solution: Solution, check_num: int = 0) -> None:
def check(checker: Check, solution: Solution, check_num: int = 0) -> CheckResult:
"""Universal check run on given solution

:param checker: check object
Expand All @@ -15,6 +15,6 @@ def check(checker: Check, solution: Solution, check_num: int = 0) -> None:
"""
match checker.category:
case CheckCategoryEnum.runtime:
runtime(checker, solution, check_num)
return runtime_wo_store(checker, solution, check_num)
case CheckCategoryEnum.validate:
validate(checker, solution, check_num)
return validate_wo_store(checker, solution, check_num)
4 changes: 2 additions & 2 deletions hworker/check/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def python_runner(
return po, result.stderr.read(), exit_code


def check_wo_store(checker: Check, solution: Solution, check_num: int = 0) -> CheckResult:
def runtime_wo_store(checker: Check, solution: Solution, check_num: int = 0) -> CheckResult:
"""Run checker on a given solution and returns result object

:param checker: check object
Expand Down Expand Up @@ -139,7 +139,7 @@ def runtime(checker: Check, solution: Solution, check_num: int = 0) -> None:
"""
get_logger(__name__).debug(f"Checking solution {solution.ID} with {checker.ID} checker")
if checker.category == CheckCategoryEnum.runtime:
result = check_wo_store(checker, solution, check_num)
result = runtime_wo_store(checker, solution, check_num)
store(result)
else:
get_logger(__name__).warning(f"The {checker.ID} object given to check is not a checker")
Expand Down
8 changes: 5 additions & 3 deletions hworker/make/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ def get_solution(hw: Homework) -> Solution:
if not path.startswith(get_check_name()):
content[path] = path_content
print(hw.content.get(f"{get_check_name()}/{get_remote_name()}", b"").decode("utf-8"))
remote_checks = loads(hw.content.get(f"{get_check_name()}/{get_remote_name()}", b"").decode("utf-8")).get("remote",
{})
remote_checks = loads(hw.content.get(f"{get_check_name()}/{get_remote_name()}", b"").decode("utf-8")).get(
"remote", {}
)
own_checks = {check.ID: [] for check in get_checks(hw)}
config_checks = get_task_info(hw.TASK_ID).get("checks", {})
solution_id = f"{hw.USER_ID}:{hw.TASK_ID}"
Expand Down Expand Up @@ -114,7 +115,8 @@ def check_solution(solution: Solution) -> None:
get_logger(__name__).debug(f"Run all checks of {solution.ID} solution")
for check_name in solution.checks:
checker = search(Check, Criteria("ID", "==", check_name), actual=True, first=True)
check(checker, solution)
check_result = check(checker, solution)
store(check_result)


def check_all_solutions() -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for check.runtime"""

from .user_config import user_config
from hworker.check.runtime import python_runner, check_wo_store
from hworker.check.runtime import python_runner, runtime_wo_store
from hworker.check.validate import validate_wo_store
from hworker.depot.objects import Check, Solution, CheckResult, CheckCategoryEnum, VerdictEnum

Expand Down Expand Up @@ -48,7 +48,7 @@ def test_checker(self, user_config):
USER_ID="user_ID",
TASK_ID="task_ID",
)
result = check_wo_store(checker, solution)
result = runtime_wo_store(checker, solution)

assert result == CheckResult(
ID=checker.ID + solution.ID,
Expand Down