dev #10

Merged
李衍志523370910113 merged 238 commits from dev into master 2025-03-05 16:20:39 +08:00
Showing only changes of commit 55da1e8482 - Show all commits

View File

@ -1,5 +1,6 @@
import re
jon-lee marked this conversation as resolved

Path should not be relative to JOJ3_CONFIG_ROOT in this file, should be relative to task.toml dir

Path should not be relative to `JOJ3_CONFIG_ROOT` in this file, should be relative to `task.toml` dir

I reckon you said things is relative to JOJ3_CONFIG_ROOT in JTC before. we have a task.type in task.toml to mend the path

I reckon you said things is relative to `JOJ3_CONFIG_ROOT` in JTC before. we have a `task.type` in `task.toml` to mend the path

config.path is relative to JOJ3_CONFIG_ROOT.

`config.path` is relative to `JOJ3_CONFIG_ROOT`.

could you explain further? I m not quite sure my understanding is clear.

could you explain further? I m not quite sure my understanding is clear.

In joj3_config_generator/models/task.py, Config.path is relative to JOJ3_CONFIG_ROOT, so task.toml will located at JOJ3_CONFIG_ROOT / task_conf.path in JTC.

In `joj3_config_generator/models/task.py`, `Config.path` is relative to `JOJ3_CONFIG_ROOT`, so `task.toml` will located at `JOJ3_CONFIG_ROOT / task_conf.path` in JTC.
import shlex
jon-lee marked this conversation as resolved

Some with_.update is still using raw dict, not model with model_dump.

Some `with_.update` is still using raw dict, not model with `model_dump`.
from pathlib import Path
from typing import Any, Callable, Dict, List, Tuple
from joj3_config_generator.models import result, task
@ -34,7 +35,10 @@ def get_conf_stage(
fn(parser_model, conf_stage.parsers[idx])
jon-lee marked this conversation as resolved Outdated

Do we need to support both kinds of names?

Do we need to support both kinds of names?

probably yes, since it is easy for new ta to type it wrong

probably yes, since it is easy for new ta to type it wrong

parsers name should be a str enum, force them to use the correct names

parsers name should be a str enum, force them to use the correct names

ok, then removed.

ok, then removed.
elif parser == "diff":
jon-lee marked this conversation as resolved Outdated

underscore

underscore

fixed

fixed
fix_diff(
task_stage, task_conf, conf_stage.parsers[idx], conf_stage.executor
task_stage,
conf_stage.parsers[idx],
conf_stage.executor,
JOJ3_CONFIG_ROOT / task_conf.path.parent,
)
else:
continue
@ -154,9 +158,9 @@ def fix_file(file_parser_config: task.ParserFile, file_parser: result.Parser) ->
def fix_diff(
task_stage: task.Stage,
jon-lee marked this conversation as resolved Outdated

move continue to the other branch to reduce nesting

move `continue` to the other branch to reduce nesting

I mean

if parser not in keyword_parser:
    continue
if getattr(task_stage, parser, None) is None:
    continue
if score != score_:
    continue
I mean ``` if parser not in keyword_parser: continue ``` ``` if getattr(task_stage, parser, None) is None: continue ```` ``` if score != score_: continue ````

fixed.

fixed.
task_conf: task.Config,
diff_parser_config: result.Parser,
diff_executor: result.Executor,
base_dir: Path,
) -> None:
skip = task_stage.skip
cases = task_stage.cases
jon-lee marked this conversation as resolved Outdated

Is it necessary to rename?

Is it necessary to rename?
@ -180,7 +184,7 @@ def fix_diff(
stage_cases.append(
result.OptionalCmd(
stdin=result.LocalFile(
src=str(JOJ3_CONFIG_ROOT / task_conf.path.parent / stdin),
src=str(base_dir / stdin),
),
args=shlex.split(command) if command else None,
jon-lee marked this conversation as resolved Outdated

Pass JOJ3_CONFIG_ROOT / task_conf.path.parent as base_dir in parameters.

Pass `JOJ3_CONFIG_ROOT / task_conf.path.parent` as `base_dir` in parameters.

resolved.

resolved.
cpu_limit=cpu_limit,
@ -203,9 +207,7 @@ def fix_diff(
result.DiffOutputConfig(
score=diff_output.score,
file_name="stdout",
answer_path=str(
JOJ3_CONFIG_ROOT / task_conf.path.parent / stdout
),
answer_path=str(base_dir / stdout),
force_quit_on_diff=diff_output.force_quit,
jon-lee marked this conversation as resolved Outdated

Create models for these dicts, then update them with the dict from model_dump

Create models for these dicts, then update them with the dict from `model_dump`

@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.

@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`.
class DummyConfig(BaseModel):
    score: int
    comment: str

Then dummy_parser_.with_.update(dummy_config(...).model_dump()).

``` class DummyConfig(BaseModel): score: int comment: str ``` Then `dummy_parser_.with_.update(dummy_config(...).model_dump())`.

fixed

fixed
always_hide=diff_output.hide,
compare_space=not diff_output.ignore_spaces,