fix(diff): bugs on diff stdin and numerics #16

Merged
张泊明518370910136 merged 22 commits from fix/diff into master 2025-05-24 02:45:39 +08:00
3 changed files with 21 additions and 29 deletions
Showing only changes of commit 927e5ce95d - Show all commits

View File

@ -200,11 +200,12 @@ def fix_diff(
)
if cmd.args == executor.with_.default.args:
cmd.args = None
if cmd.cpu_limit == executor.with_.default.cpu_limit:
# duplicate with the fallback case in executor.with_
if cmd.cpu_limit == const.DEFAULT_CPU_LIMIT:
bomingzh marked this conversation as resolved Outdated

What if the with_.default.cpu_limit is not the same as DEFAULT_CPU_LIMIT? Why do we need to set these fields to none?

What if the `with_.default.cpu_limit` is not the same as `DEFAULT_CPU_LIMIT`? Why do we need to set these fields to none?

if the with_.default.cpu_limit is not the same as DEFAULT_CPU_LIMIT it means its already been input before, and it is considered as the new default value for all cases (ta might want to control it). If I dont set these field to none, it will use DEFAULT_CPU_LIMIT instead of those ta input, which is not intended. It solve the second problem in #15

if the `with_.default.cpu_limit` is not the same as `DEFAULT_CPU_LIMIT` it means its already been input before, and it is considered as the new default value for all cases (ta might want to control it). If I dont set these field to none, it will use `DEFAULT_CPU_LIMIT` instead of those ta input, which is not intended. It solve the second problem in https://focs.ji.sjtu.edu.cn/git/JOJ/JOJ3-config-generator/issues/15

Which test case will show this problem?

Which test case will show this problem?

We need another pydantic model for auto detected cases. Fields in these cases can be none, which means they are not set and should use with_.default values.

We need another pydantic model for auto detected cases. Fields in these cases can be none, which means they are not set and should use `with_.default` values.
cmd.cpu_limit = None
if cmd.clock_limit == executor.with_.default.clock_limit:
if cmd.clock_limit == 2 * const.DEFAULT_CPU_LIMIT:
cmd.clock_limit = None
if cmd.memory_limit == executor.with_.default.memory_limit:
if cmd.memory_limit == const.DEFAULT_MEMORY_LIMIT:
cmd.memory_limit = None
if cmd.proc_limit == executor.with_.default.proc_limit:
cmd.proc_limit = None
@ -224,18 +225,11 @@ def fix_diff(
parser_cases.append(parser_case)
for case in default_cases:
cmd = result.OptionalCmd(
stdin=result.LocalFile(src=str(base_dir / f"{case}.in"))
stdin=result.LocalFile(src=str(base_dir / f"{case}.in")),
cpu_limit=None,
clock_limit=None,
memory_limit=None,
)
if cmd.args == executor.with_.default.args:
cmd.args = None
if cmd.cpu_limit == executor.with_.default.cpu_limit:
cmd.cpu_limit = None
if cmd.clock_limit == executor.with_.default.clock_limit:
cmd.clock_limit = None
if cmd.memory_limit == executor.with_.default.memory_limit:
cmd.memory_limit = None
if cmd.proc_limit == executor.with_.default.proc_limit:
cmd.proc_limit = None
stage_cases.append(cmd)
parser_case = result.DiffCasesConfig(
outputs=[

View File

@ -26,17 +26,17 @@
],
"stdout": {
"name": "stdout",
"max": 33554432,
"max": 10485760,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 33554432,
"max": 10485760,
"pipe": true
},
"cpuLimit": 1000000000,
"clockLimit": 2000000000,
"memoryLimit": 68157440,
"cpuLimit": 3000000000,
"clockLimit": 6000000000,
"memoryLimit": 10485760,
"stackLimit": 0,
"procLimit": 50,
"cpuRateLimit": 0,
@ -84,26 +84,22 @@
{
"stdin": {
"src": "/home/tt/.config/joj/diff/case9.in"
},
"memoryLimit": 268435456
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task1/subtask1/case11.in"
},
"memoryLimit": 268435456
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task1/subtask1/case10.in"
},
"memoryLimit": 268435456
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task1/case5.in"
},
"memoryLimit": 268435456
}
},
{
"stdin": {

View File

@ -8,7 +8,10 @@ release.begin_time = 2024-12-29 23:59:59+08:00
name = "[joj] ex2-asan"
command="./h7/build/ex2-asan -a"
files.import = [ "h7/build/ex2-asan" ]
limit.mem = "65m"
limit.cpu = "3s"
limit.mem = "10m"
limit.stdout = "10m"
limit.stderr = "10m"
parsers = [ "diff", "result-detail" ]
result-detail.exitstatus = true
@ -16,7 +19,6 @@ result-detail.stderr = true
diff.default_score = 100
# will be removed as long as the name is fixed
case0.diff.output.score = 5
case0.limit.cpu = "1s"
case0.limit.mem = "2m"