dev #10
|
@ -10,7 +10,7 @@ def get_conf_stage(
|
|||
task_stage: task.Stage, executor_with_config: result.ExecutorWith
|
||||
) -> result.StageDetail:
|
||||
conf_stage = result.StageDetail(
|
||||
name=task_stage.name if task_stage.name is not None else "",
|
||||
name=task_stage.name,
|
||||
# group is determined by adding between "[]" in the name of the task
|
||||
# FIXME: this is probably outdated
|
||||
group=(
|
||||
jon-lee marked this conversation as resolved
Outdated
|
||||
|
@ -27,8 +27,6 @@ def get_conf_stage(
|
|||
result.ParserConfig(name=parser, with_={})
|
||||
for parser in task_stage.parsers
|
||||
]
|
||||
if task_stage.parsers is not None
|
||||
else []
|
||||
),
|
||||
)
|
||||
return conf_stage
|
||||
|
@ -43,11 +41,7 @@ def get_executor_with_config(
|
|||
copy_out_files = ["stdout", "stderr"]
|
||||
executor_with_config = result.ExecutorWith(
|
||||
default=result.Cmd(
|
||||
args=(
|
||||
shlex.split(task_stage.command)
|
||||
if task_stage.command is not None
|
||||
else []
|
||||
),
|
||||
args=shlex.split(task_stage.command),
|
||||
copy_in={
|
||||
file: result.LocalFile(src=str(JOJ3_CONFIG_ROOT / file))
|
||||
# all copyin files store in this tools folder
|
||||
|
@ -56,7 +50,7 @@ def get_executor_with_config(
|
|||
},
|
||||
copy_out=copy_out_files,
|
||||
copy_in_cached={file: file for file in cached},
|
||||
copy_out_cached=file_export or [],
|
||||
copy_out_cached=file_export,
|
||||
cpu_limit=task_stage.limit.cpu,
|
||||
clock_limit=2 * task_stage.limit.cpu,
|
||||
memory_limit=task_stage.limit.mem,
|
||||
|
@ -65,10 +59,9 @@ def get_executor_with_config(
|
|||
),
|
||||
cases=[],
|
||||
)
|
||||
if file_export is not None:
|
||||
for file in file_export:
|
||||
if file not in cached:
|
||||
cached.append(file)
|
||||
for file in file_export:
|
||||
if file not in cached:
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
not necessary not necessary
李衍志523370910113
commented
resolved. resolved.
|
||||
cached.append(file)
|
||||
return (executor_with_config, cached)
|
||||
|
||||
|
||||
|
@ -76,7 +69,7 @@ def fix_keyword(
|
|||
task_stage: task.Stage, conf_stage: result.StageDetail
|
||||
) -> result.StageDetail:
|
||||
keyword_parser = ["clangtidy", "keyword", "cppcheck", "cpplint"]
|
||||
for parser in task_stage.parsers or []:
|
||||
for parser in task_stage.parsers:
|
||||
if parser in keyword_parser:
|
||||
keyword_parser_ = next(p for p in conf_stage.parsers if p.name == parser)
|
||||
keyword_weight = []
|
||||
|
@ -107,26 +100,26 @@ def fix_keyword(
|
|||
def fix_result_detail(
|
||||
task_stage: task.Stage, conf_stage: result.StageDetail
|
||||
) -> result.StageDetail:
|
||||
if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers):
|
||||
result_detail_parser = next(
|
||||
p for p in conf_stage.parsers if p.name == "result-detail"
|
||||
)
|
||||
if task_stage.result_detail is not None:
|
||||
show_files = []
|
||||
if task_stage.result_detail.stdout:
|
||||
show_files.append("stdout")
|
||||
if task_stage.result_detail.stderr:
|
||||
show_files.append("stderr")
|
||||
result_detail_parser.with_.update(
|
||||
result.ResultDetailConfig(
|
||||
score=0,
|
||||
comment="",
|
||||
show_files=show_files,
|
||||
show_exit_status=task_stage.result_detail.exitstatus,
|
||||
show_runtime=task_stage.result_detail.time,
|
||||
show_memory=task_stage.result_detail.mem,
|
||||
).model_dump(by_alias=True)
|
||||
)
|
||||
if "result-detail" not in task_stage.parsers:
|
||||
return conf_stage
|
||||
result_detail_parser = next(
|
||||
p for p in conf_stage.parsers if p.name == "result-detail"
|
||||
)
|
||||
show_files = []
|
||||
if task_stage.result_detail.stdout:
|
||||
show_files.append("stdout")
|
||||
if task_stage.result_detail.stderr:
|
||||
show_files.append("stderr")
|
||||
result_detail_parser.with_.update(
|
||||
result.ResultDetailConfig(
|
||||
score=0,
|
||||
comment="",
|
||||
show_files=show_files,
|
||||
show_exit_status=task_stage.result_detail.exitstatus,
|
||||
show_runtime=task_stage.result_detail.time,
|
||||
show_memory=task_stage.result_detail.mem,
|
||||
).model_dump(by_alias=True)
|
||||
)
|
||||
|
||||
return conf_stage
|
||||
|
||||
|
@ -138,22 +131,21 @@ def fix_dummy(
|
|||
"dummy",
|
||||
"result-status",
|
||||
]
|
||||
if task_stage.parsers is not None:
|
||||
for parser in task_stage.parsers:
|
||||
if parser not in dummy_parser:
|
||||
continue
|
||||
dummy_parser_ = next(p for p in conf_stage.parsers if p.name == parser)
|
||||
if getattr(task_stage, parser.replace("-", "_"), None) is None:
|
||||
continue
|
||||
if task_stage.result_status is None:
|
||||
continue
|
||||
dummy_parser_.with_.update(
|
||||
result.DummyConfig(
|
||||
score=task_stage.result_status.score,
|
||||
comment=task_stage.result_status.comment,
|
||||
force_quit_on_not_accepted=task_stage.result_status.force_quit,
|
||||
).model_dump(by_alias=True)
|
||||
)
|
||||
for parser in task_stage.parsers:
|
||||
if parser not in dummy_parser:
|
||||
continue
|
||||
dummy_parser_ = next(p for p in conf_stage.parsers if p.name == parser)
|
||||
if getattr(task_stage, parser.replace("-", "_"), None) is None:
|
||||
continue
|
||||
if task_stage.result_status is None:
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
When will it be None? When will it be None?
|
||||
continue
|
||||
dummy_parser_.with_.update(
|
||||
result.DummyConfig(
|
||||
score=task_stage.result_status.score,
|
||||
comment=task_stage.result_status.comment,
|
||||
force_quit_on_not_accepted=task_stage.result_status.force_quit,
|
||||
).model_dump(by_alias=True)
|
||||
)
|
||||
return conf_stage
|
||||
|
||||
|
||||
|
@ -161,14 +153,11 @@ def fix_file(
|
|||
task_stage: task.Stage, conf_stage: result.StageDetail
|
||||
) -> result.StageDetail:
|
||||
file_parser = ["file"]
|
||||
bomingzh marked this conversation as resolved
Outdated
张泊明518370910136
commented
these fields do not exist now these fields do not exist now
李衍志523370910113
commented
resolved resolved
张泊明518370910136
commented
No description provided.
|
||||
if task_stage.parsers is not None:
|
||||
for parser in task_stage.parsers:
|
||||
if parser in file_parser:
|
||||
file_parser_ = next(p for p in conf_stage.parsers if p.name == parser)
|
||||
if task_stage.file is not None:
|
||||
file_parser_.with_.update({"name": task_stage.file.name})
|
||||
else:
|
||||
continue
|
||||
for parser in task_stage.parsers:
|
||||
if parser not in file_parser:
|
||||
continue
|
||||
file_parser_ = next(p for p in conf_stage.parsers if p.name == parser)
|
||||
file_parser_.with_.update({"name": task_stage.file.name})
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
move move `continue` to the other branch to reduce nesting
张泊明518370910136
commented
I mean
I mean
```
if parser not in keyword_parser:
continue
```
```
if getattr(task_stage, parser, None) is None:
continue
````
```
if score != score_:
continue
````
李衍志523370910113
commented
fixed. fixed.
|
||||
return conf_stage
|
||||
|
||||
|
||||
|
@ -177,66 +166,67 @@ def fix_diff(
|
|||
conf_stage: result.StageDetail,
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
Is it necessary to rename? Is it necessary to rename?
|
||||
task_conf: task.Config,
|
||||
) -> result.StageDetail:
|
||||
if task_stage.parsers is not None and "diff" in task_stage.parsers:
|
||||
diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None)
|
||||
skip = task_stage.skip or []
|
||||
cases = task_stage.cases or {}
|
||||
finalized_cases = [case for case in cases if case not in skip]
|
||||
if "diff" not in task_stage.parsers:
|
||||
return conf_stage
|
||||
diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None)
|
||||
skip = task_stage.skip
|
||||
cases = task_stage.cases
|
||||
finalized_cases = [case for case in cases if case not in skip]
|
||||
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
just just `if task_stage.result_detail.stdout:`
|
||||
stage_cases = []
|
||||
parser_cases = []
|
||||
stage_cases = []
|
||||
parser_cases = []
|
||||
|
||||
for case in finalized_cases:
|
||||
case_stage = task_stage.cases.get(case) if task_stage.cases else None
|
||||
if not case_stage:
|
||||
continue
|
||||
for case in finalized_cases:
|
||||
case_stage = task_stage.cases.get(case) if task_stage.cases else None
|
||||
if not case_stage:
|
||||
continue
|
||||
|
||||
cpu_limit = case_stage.limit.cpu
|
||||
clock_limit = 2 * case_stage.limit.cpu
|
||||
memory_limit = case_stage.limit.mem
|
||||
command = case_stage.command if case_stage.command is not None else None
|
||||
stdin = case_stage.in_ if case_stage.in_ != "" else f"{case}.in"
|
||||
stdout = case_stage.out_ if case_stage.out_ != "" else f"{case}.out"
|
||||
cpu_limit = case_stage.limit.cpu
|
||||
clock_limit = 2 * case_stage.limit.cpu
|
||||
memory_limit = case_stage.limit.mem
|
||||
command = case_stage.command
|
||||
stdin = case_stage.in_ if case_stage.in_ != "" else f"{case}.in"
|
||||
stdout = case_stage.out_ if case_stage.out_ != "" else f"{case}.out"
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
Pass Pass `JOJ3_CONFIG_ROOT / task_conf.path.parent` as `base_dir` in parameters.
李衍志523370910113
commented
resolved. resolved.
|
||||
|
||||
stage_cases.append(
|
||||
result.OptionalCmd(
|
||||
stdin=result.LocalFile(
|
||||
src=str(JOJ3_CONFIG_ROOT / task_conf.task.type_ / stdin),
|
||||
),
|
||||
args=(shlex.split(command) if command is not None else None),
|
||||
cpu_limit=cpu_limit,
|
||||
clock_limit=clock_limit,
|
||||
memory_limit=memory_limit,
|
||||
proc_limit=50,
|
||||
)
|
||||
stage_cases.append(
|
||||
result.OptionalCmd(
|
||||
stdin=result.LocalFile(
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
will it be None now? will it be None now?
李衍志523370910113
commented
nope 😂 bad coding strategy before nope 😂 bad coding strategy before
|
||||
src=str(JOJ3_CONFIG_ROOT / task_conf.task.type_ / stdin),
|
||||
),
|
||||
args=shlex.split(command) if command else None,
|
||||
cpu_limit=cpu_limit,
|
||||
clock_limit=clock_limit,
|
||||
memory_limit=memory_limit,
|
||||
proc_limit=50,
|
||||
)
|
||||
)
|
||||
|
||||
# Ensure case_stage.diff and case_stage.diff.output are defined
|
||||
diff_output = (
|
||||
case_stage.diff.output
|
||||
if case_stage.diff and case_stage.diff.output
|
||||
else None
|
||||
)
|
||||
if diff_output:
|
||||
parser_cases.append(
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
Create models for these dicts, then update them with the dict from Create models for these dicts, then update them with the dict from `model_dump`
李衍志523370910113
commented
@bomingzh I don't think we can change it. This is to make proper alias so that we can get the content of @bomingzh I don't think we can change it. This is to make proper alias so that we can get the content of `result-status`.
张泊明518370910136
commented
Then ```
class DummyConfig(BaseModel):
score: int
comment: str
```
Then `dummy_parser_.with_.update(dummy_config(...).model_dump())`.
李衍志523370910113
commented
fixed fixed
|
||||
{
|
||||
"outputs": [
|
||||
result.DiffOutputConfig(
|
||||
score=diff_output.score,
|
||||
file_name="stdout",
|
||||
answer_path=str(
|
||||
JOJ3_CONFIG_ROOT / task_conf.task.type_ / stdout
|
||||
),
|
||||
force_quit_on_diff=diff_output.force_quit,
|
||||
always_hide=diff_output.hide,
|
||||
compare_space=not diff_output.ignore_spaces,
|
||||
).model_dump(by_alias=True)
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
When will it be None? When will it be None?
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
Just pass Just pass `conf_stage.executor` to this function rather then the whole `conf_stage`.
|
||||
# Ensure case_stage.diff and case_stage.diff.output are defined
|
||||
diff_output = (
|
||||
case_stage.diff.output
|
||||
if case_stage.diff and case_stage.diff.output
|
||||
else None
|
||||
)
|
||||
if diff_output:
|
||||
parser_cases.append(
|
||||
{
|
||||
"outputs": [
|
||||
result.DiffOutputConfig(
|
||||
score=diff_output.score,
|
||||
file_name="stdout",
|
||||
answer_path=str(
|
||||
JOJ3_CONFIG_ROOT / task_conf.task.type_ / stdout
|
||||
),
|
||||
force_quit_on_diff=diff_output.force_quit,
|
||||
always_hide=diff_output.hide,
|
||||
compare_space=not diff_output.ignore_spaces,
|
||||
).model_dump(by_alias=True)
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
if diff_parser and task_stage.diff is not None:
|
||||
diff_parser.with_.update({"name": "diff", "cases": parser_cases})
|
||||
conf_stage.executor.with_.cases = stage_cases
|
||||
if diff_parser:
|
||||
diff_parser.with_.update({"name": "diff", "cases": parser_cases})
|
||||
conf_stage.executor.with_.cases = stage_cases
|
||||
|
||||
return conf_stage
|
||||
|
|
|
@ -660,7 +660,6 @@
|
|||
},
|
||||
"cases": [
|
||||
{
|
||||
"args": [],
|
||||
"stdin": {
|
||||
"src": "/home/tt/.config/joj/homework/h7/e2/case0.in"
|
||||
},
|
||||
|
@ -670,7 +669,6 @@
|
|||
"procLimit": 50
|
||||
},
|
||||
{
|
||||
"args": [],
|
||||
"stdin": {
|
||||
"src": "/home/tt/.config/joj/homework/h7/e2/case1.in"
|
||||
},
|
||||
|
|
|
@ -63,7 +63,6 @@
|
|||
},
|
||||
"cases": [
|
||||
{
|
||||
"args": [],
|
||||
"stdin": {
|
||||
"src": "/home/tt/.config/joj/homework/h7/e2/case0.in"
|
||||
},
|
||||
|
@ -73,7 +72,6 @@
|
|||
"procLimit": 50
|
||||
},
|
||||
{
|
||||
"args": [],
|
||||
"stdin": {
|
||||
"src": "/home/tt/.config/joj/homework/h7/e2/case1.in"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user
BTW, is this outdated?
Never heard about this rule.
@manuel what would be the current intended rule for
group
?seems current strategy is fine, resolved.