dev #10

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

View File

@ -6,7 +6,7 @@ from typing import Any, Callable, Dict, List, Tuple
from joj3_config_generator.models import result, task
from joj3_config_generator.models.common import Memory, Time
from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
from joj3_config_generator.models.task import Parser as parser_enum
from joj3_config_generator.models.task import Parser as ParserEnum
jon-lee marked this conversation as resolved Outdated

ParserEnum

`ParserEnum`
def get_conf_stage(
@ -33,7 +33,7 @@ def get_conf_stage(
if parser in processed_dict:
fn, parser_model = processed_dict[parser]
jon-lee marked this conversation as resolved Outdated

should loop through conf_stage.parsers here and update the with field according to the parser name.

should loop through `conf_stage.parsers` here and update the `with` field according to the parser name.

I think its already implemented in each of the fix_parsers functions

I think its already implemented in each of the `fix_parsers` functions

No, do not find the parser in the fix_xxx function. Instead, iterate through the parsers here and decide how to fill in the with.

No, do not find the parser in the `fix_xxx` function. Instead, iterate through the parsers here and decide how to fill in the `with`.

resolved.

resolved.

Use a dict to store parser name, field, function to process.

    process_dict: Dict[
        str, Tuple[Callable[[result.ParserConfig, BaseModel], None], BaseModel]
    ] = {
        "clangtidy": (fix_keyword, task_stage.clangtidy),
        "keyword": (fix_keyword, task_stage.keyword),
        "diff": (fix_diff, task_stage.diff),
    }
    for i, parser in enumerate(task_stage.parsers):
        if parser in process_dict:
            func, parser_model = process_dict[parser]
            func(conf_stage.parsers[i], parser_model)
Use a dict to store parser name, field, function to process. ``` process_dict: Dict[ str, Tuple[Callable[[result.ParserConfig, BaseModel], None], BaseModel] ] = { "clangtidy": (fix_keyword, task_stage.clangtidy), "keyword": (fix_keyword, task_stage.keyword), "diff": (fix_diff, task_stage.diff), } for i, parser in enumerate(task_stage.parsers): if parser in process_dict: func, parser_model = process_dict[parser] func(conf_stage.parsers[i], parser_model) ```

resolved.

resolved.
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 == parser_enum.DIFF:
elif parser == ParserEnum.DIFF:
jon-lee marked this conversation as resolved Outdated

underscore

underscore

fixed

fixed
fix_diff(
task_stage,
conf_stage.parsers[idx],
@ -47,18 +47,18 @@ def get_conf_stage(
def get_processed_dict(
task_stage: task.Stage,
) -> Dict[parser_enum, Tuple[Callable[[Any, result.Parser], None], Any]]:
) -> Dict[ParserEnum, Tuple[Callable[[Any, result.Parser], None], Any]]:
processed_dict: Dict[
parser_enum, Tuple[Callable[[Any, result.Parser], None], Any]
ParserEnum, Tuple[Callable[[Any, result.Parser], None], Any]
] = {
parser_enum.CLANG_TIDY: (fix_keyword, task_stage.clangtidy),
parser_enum.KEYWORD: (fix_keyword, task_stage.keyword),
parser_enum.CPPCHECK: (fix_keyword, task_stage.cppcheck),
parser_enum.CPPLINT: (fix_keyword, task_stage.cpplint),
parser_enum.RESULT_DETAIL: (fix_result_detail, task_stage.result_detail),
parser_enum.DUMMY: (fix_dummy, task_stage.dummy),
parser_enum.RESULT_STATUS: (fix_dummy, task_stage.result_status),
parser_enum.FILE: (fix_file, task_stage.file),
ParserEnum.CLANG_TIDY: (fix_keyword, task_stage.clangtidy),
ParserEnum.KEYWORD: (fix_keyword, task_stage.keyword),
ParserEnum.CPPCHECK: (fix_keyword, task_stage.cppcheck),
ParserEnum.CPPLINT: (fix_keyword, task_stage.cpplint),
ParserEnum.RESULT_DETAIL: (fix_result_detail, task_stage.result_detail),
ParserEnum.DUMMY: (fix_dummy, task_stage.dummy),
ParserEnum.RESULT_STATUS: (fix_dummy, task_stage.result_status),
ParserEnum.FILE: (fix_file, task_stage.file),
}
return processed_dict
jon-lee marked this conversation as resolved Outdated

not necessary

not necessary

resolved.

resolved.