Skip to content

Commit

Permalink
feat: 区分前台后台样例
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Dong123 committed Sep 28, 2024
1 parent a061075 commit 84d18da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/judge_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ def __init__(
max_memory,
test_case_dir,
submission_dir,

spj_version,
spj_config,
io_mode,
include_sample=True,
output=False,
):
self._language_config = language_config
Expand All @@ -61,6 +63,7 @@ def __init__(
self._spj_config = spj_config
self._output = output
self._io_mode = io_mode
self._include_sample = include_sample

if self._spj_version and self._spj_config:
self._spj_exe = os.path.join(
Expand Down Expand Up @@ -168,6 +171,7 @@ def _judge_one(self, test_case_file_id):
test_case_info = self._get_test_case_file_info(test_case_file_id)
in_file = os.path.join(self._test_case_dir, test_case_info["input_name"])
ans_file = os.path.join(self._test_case_dir, test_case_info["output_name"])
is_sample = test_case_info["is_sample"]

if self._io_mode["io_mode"] == ProblemIOMode.file:
user_output_dir = os.path.join(self._submission_dir, str(test_case_file_id))
Expand Down Expand Up @@ -230,6 +234,7 @@ def _judge_one(self, test_case_file_id):
# if progress exited normally, then we should check output result
run_result["output_md5"] = None
run_result["output"] = None
run_result["is_sample"] = is_sample
if run_result["result"] == judger.RESULT_SUCCESS:
if not os.path.exists(user_output_file):
run_result["result"] = judger.RESULT_WRONG_ANSWER
Expand Down Expand Up @@ -272,7 +277,9 @@ def run(self):
result = []
pool = Pool(processes=psutil.cpu_count())
try:
for test_case_file_id, _ in self._test_case_info["test_cases"].items():
for test_case_file_id, case_info in self._test_case_info["test_cases"].items():
if not self._include_sample and case_info["is_sample"]:
continue
tmp_result.append(pool.apply_async(_run, (self, test_case_file_id)))
except Exception as e:
raise e
Expand Down
5 changes: 5 additions & 0 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def judge(
max_cpu_time,
max_memory,
options: Optional[OptionType] = None,
include_sample=True,
test_case_id=None,
test_case=None,
spj_version=None,
Expand All @@ -103,6 +104,7 @@ def judge(
:param spj_compile_config:
:param spj_src:
:param output:
:param include_sample: 评测是否包含样例
:param io_mode: {'io_mode': ...(, 'input': ..., 'output': ...)}
:return:
"""
Expand Down Expand Up @@ -140,6 +142,8 @@ def judge(
spj_compile_config=spj_compile_config,
)


# 目前都是后端生成测试用例, 无需判题端生成
init_test_case_dir = bool(test_case)
with InitSubmissionEnv(
JUDGER_WORKSPACE_BASE,
Expand Down Expand Up @@ -228,6 +232,7 @@ def judge(
spj_config=spj_config,
output=output,
io_mode=io_mode,
include_sample=include_sample,
)
run_result = judge_client.run()

Expand Down

0 comments on commit 84d18da

Please sign in to comment.