Skip to content

Commit

Permalink
Single check from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
George V. Kouryachy (Fr. Br. George) committed Oct 23, 2023
1 parent 2532865 commit 87cecd4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hworker/control/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,18 @@ def do_check(self, arg):
make.check_new_solutions()
case ["all"]:
make.check_all_solutions()
case [ID]:
sol = depot.search(depot.objects.Solution, Rule("ID", "==", ID), actual=True, first=True)
for name, result in make.run_solution_checks(sol).items():
print(f"{name}: {result}")

def complete_check(self, text, line, begidx, endidx):
objnames = ("all", "new")
return self.filtertext(objnames, text)
(_, *args, word), delta, quote = self.qsplit(line, text, begidx, endidx)
const = ["all", "new"]
ids = [sol.ID for sol in depot.search(depot.objects.Solution, actual=True)]
match args:
case []:
return self.filtertext(ids + const, text)

def do_logging(self, arg):
"""Set console log level"""
Expand Down
15 changes: 15 additions & 0 deletions hworker/make/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ def run_solution_checks_and_store(solution: Solution) -> None:
store(check_result)


def run_solution_checks(solution: Solution) -> dict[str:CheckResult]:
"""Run all given solution checks and store results in depot
:param solution: solution to run checks
:return: {check_name: CheckResult} dictionary
"""
get_logger(__name__).debug(f"Run all checks of {solution.ID} solution")

check_results = {}
for check_name in solution.checks:
checker = search(Check, Criteria("ID", "==", check_name), first=True)
check_results[check_name] = check(checker, solution)
return check_results


def check_all_solutions() -> None:
"""Run all solution checks for every actual solution and store results in depot
Expand Down

0 comments on commit 87cecd4

Please sign in to comment.