From 275f9f981c7d7555c03f195e072b07aaae30e1b7 Mon Sep 17 00:00:00 2001 From: jon-lee Date: Tue, 4 Mar 2025 13:34:25 +0800 Subject: [PATCH] fix: use task.config.path --- joj3_config_generator/processers/task.py | 23 ++++++++++++-- tests/convert/basic/task.json | 38 ++++++++++++------------ tests/convert/diff/task.json | 8 ++--- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 179188b..16845b8 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,6 +1,8 @@ import re import shlex -from typing import List, Set +from typing import Callable, Dict, List, Set, Tuple + +from pydantic import BaseModel from joj3_config_generator.models import result, task from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT @@ -48,6 +50,21 @@ def get_conf_stage( return conf_stage +# def get_processed_dict(task_stage: task.Stagew) -> Dict[str, Tuple[Callable[[task.Stage, BaseModel], None], BaseModel]]: +# processed_dict: Dict[str, Tuple[Callable[[task.Stage, task.StageDetail], None], BaseModel]] = { +# "clang-tidy": (fix_keyword, result.clang-tidy), +# "keyword": (fix_keyword, result.KeywordConfig), +# "cppcheck": (fix_keyword, result.KeywordConfig), +# "cpplint": (fix_keyword, result.KeywordConfig), +# "result-detail": (fix_result_detail, result.ResultDetailConfig), +# "dummy": (fix_dummy, result.DummyConfig), +# "result-status": (fix_dummy, result.DummyConfig), +# "file": (fix_file, result.FileConfig), +# "diff": (fix_diff, result.DiffConfig), +# } +# return processed_dict + + def get_executor_with(task_stage: task.Stage, cached: Set[str]) -> result.ExecutorWith: file_import = task_stage.files.import_ copy_in_files = [file for file in file_import if file not in cached] @@ -183,7 +200,7 @@ def fix_diff( stage_cases.append( result.OptionalCmd( stdin=result.LocalFile( - src=str(JOJ3_CONFIG_ROOT / task_conf.task.type_ / stdin), + src=str(JOJ3_CONFIG_ROOT / task_conf.path.parent / stdin), ), args=shlex.split(command) if command else None, cpu_limit=cpu_limit, @@ -207,7 +224,7 @@ def fix_diff( score=diff_output.score, file_name="stdout", answer_path=str( - JOJ3_CONFIG_ROOT / task_conf.task.type_ / stdout + JOJ3_CONFIG_ROOT / task_conf.path.parent / stdout ), force_quit_on_diff=diff_output.force_quit, always_hide=diff_output.hide, diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index e24a2c6..ec0db61 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -223,10 +223,10 @@ }, "copyInCached": { "h7/build/compile_commands.json": "h7/build/compile_commands.json", - "h7/build/ex2-msan": "h7/build/ex2-msan", - "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", - "h7/build/ex2-asan": "h7/build/ex2-asan" + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/ex2": "h7/build/ex2" }, "copyInDir": ".", "copyOut": [ @@ -323,10 +323,10 @@ }, "copyInCached": { "h7/build/compile_commands.json": "h7/build/compile_commands.json", - "h7/build/ex2-msan": "h7/build/ex2-msan", - "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", - "h7/build/ex2-asan": "h7/build/ex2-asan" + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/ex2": "h7/build/ex2" }, "copyInDir": ".", "copyOut": [ @@ -445,10 +445,10 @@ "copyIn": {}, "copyInCached": { "h7/build/compile_commands.json": "h7/build/compile_commands.json", - "h7/build/ex2-msan": "h7/build/ex2-msan", - "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", - "h7/build/ex2-asan": "h7/build/ex2-asan" + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/ex2": "h7/build/ex2" }, "copyInDir": ".", "copyOut": [ @@ -588,10 +588,10 @@ "copyIn": {}, "copyInCached": { "h7/build/compile_commands.json": "h7/build/compile_commands.json", - "h7/build/ex2-msan": "h7/build/ex2-msan", - "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", - "h7/build/ex2-asan": "h7/build/ex2-asan" + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/ex2": "h7/build/ex2" }, "copyInDir": ".", "copyOut": [ @@ -685,10 +685,10 @@ "copyIn": {}, "copyInCached": { "h7/build/compile_commands.json": "h7/build/compile_commands.json", - "h7/build/ex2-msan": "h7/build/ex2-msan", - "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", - "h7/build/ex2-asan": "h7/build/ex2-asan" + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/ex2": "h7/build/ex2" }, "copyInDir": ".", "copyOut": [ @@ -706,7 +706,7 @@ "cases": [ { "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case0.in" + "src": "/home/tt/.config/joj/case0.in" }, "cpuLimit": 500000000, "clockLimit": 1000000000, @@ -715,7 +715,7 @@ }, { "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case1.in" + "src": "/home/tt/.config/joj/case1.in" }, "cpuLimit": 1234567890, "clockLimit": 2469135780, @@ -736,7 +736,7 @@ { "score": 5, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", + "answerPath": "/home/tt/.config/joj/case0.out", "forceQuitOnDiff": false, "alwaysHide": false, "compareSpace": false @@ -748,7 +748,7 @@ { "score": 5, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", + "answerPath": "/home/tt/.config/joj/case1.out", "forceQuitOnDiff": false, "alwaysHide": false, "compareSpace": false diff --git a/tests/convert/diff/task.json b/tests/convert/diff/task.json index 99c8583..9f1f1da 100644 --- a/tests/convert/diff/task.json +++ b/tests/convert/diff/task.json @@ -64,7 +64,7 @@ "cases": [ { "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case0.in" + "src": "/home/tt/.config/joj/case0.in" }, "cpuLimit": 1000000000, "clockLimit": 2000000000, @@ -73,7 +73,7 @@ }, { "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case1.in" + "src": "/home/tt/.config/joj/case1.in" }, "cpuLimit": 2000000000, "clockLimit": 4000000000, @@ -94,7 +94,7 @@ { "score": 5, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", + "answerPath": "/home/tt/.config/joj/case0.out", "forceQuitOnDiff": false, "alwaysHide": false, "compareSpace": false @@ -106,7 +106,7 @@ { "score": 5, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", + "answerPath": "/home/tt/.config/joj/case1.out", "forceQuitOnDiff": false, "alwaysHide": false, "compareSpace": false