dev #10
|  | @ -31,11 +31,21 @@ def get_conf_stage( | |||
|             ] | ||||
|         ), | ||||
|     ) | ||||
|     fix_result_detail(task_stage, conf_stage) | ||||
|     fix_dummy(task_stage, conf_stage) | ||||
|     fix_keyword(task_stage, conf_stage) | ||||
|     fix_file(task_stage, conf_stage) | ||||
|     fix_diff(task_stage, task_conf, conf_stage) | ||||
|     keyword_parser = ["clangtidy", "keyword", "cppcheck", "cpplint"] | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 | ||||
|     dummy_parser = ["dummy", "result-status"] | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  Do we need to support both kinds of names? Do we need to support both kinds of names? 
				
					
						李衍志523370910113
						commented  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 
				
					
						张泊明518370910136
						commented  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 
				
					
						李衍志523370910113
						commented  ok, then removed. ok, then removed. | ||||
|     for parser in task_stage.parsers: | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  underscore underscore 
				
					
						李衍志523370910113
						commented  fixed fixed | ||||
|         if parser in keyword_parser: | ||||
|             fix_keyword(task_stage, conf_stage, parser) | ||||
|         elif parser in dummy_parser: | ||||
|             fix_dummy(task_stage, conf_stage, parser) | ||||
|         elif parser == "result-detail": | ||||
|             fix_result_detail(task_stage, conf_stage, parser) | ||||
|         elif parser == "file": | ||||
|             fix_file(task_stage, conf_stage, parser) | ||||
|         elif parser == "diff": | ||||
|             fix_diff(task_stage, task_conf, conf_stage, parser) | ||||
|         else: | ||||
|             continue | ||||
|     return conf_stage | ||||
| 
 | ||||
| 
 | ||||
|  | @ -70,42 +80,36 @@ def get_executor_with(task_stage: task.Stage, cached: Set[str]) -> result.Execut | |||
| 
 | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  is it in the correct unit? is it in the correct unit?
Give all the fields in `Limit` a default value and make it non optional in task_stage.limit 
				
					
						李衍志523370910113
						commented  resolved resolved | ||||
| 
 | ||||
| def fix_keyword( | ||||
|     task_stage: task.Stage, conf_stage: result.StageDetail | ||||
|     task_stage: task.Stage, conf_stage: result.StageDetail, parser: str | ||||
| ) -> result.StageDetail: | ||||
|     keyword_parser = ["clangtidy", "keyword", "cppcheck", "cpplint"] | ||||
|     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: List[result.KeywordConfig] = [] | ||||
|             if parser in task_stage.__dict__: | ||||
|                 unique_weight = list(set(task_stage.__dict__[parser].weight)) | ||||
|                 for score in unique_weight: | ||||
|                     keyword_weight.append( | ||||
|                         result.KeywordConfig(keywords=[], score=score) | ||||
|     keyword_parser_ = next(p for p in conf_stage.parsers if p.name == parser) | ||||
|     keyword_weight: List[result.KeywordConfig] = [] | ||||
|     if parser in task_stage.__dict__: | ||||
|         unique_weight = list(set(task_stage.__dict__[parser].weight)) | ||||
|         for score in unique_weight: | ||||
|             keyword_weight.append(result.KeywordConfig(keywords=[], score=score)) | ||||
| 
 | ||||
|         for idx, score in enumerate(unique_weight): | ||||
|             for idx_, score_ in enumerate(task_stage.__dict__[parser].weight): | ||||
|                 if score == score_: | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  The reason for the suffix in  The reason for the suffix in `keyword_parser_`? 
				
					
						李衍志523370910113
						commented  just forgot to remove, sorry just forgot to remove, sorry | ||||
|                     keyword_weight[idx].keywords.append( | ||||
|                         task_stage.__dict__[parser].keyword[idx_] | ||||
|                     ) | ||||
|                 else: | ||||
|                     continue | ||||
| 
 | ||||
|                 for idx, score in enumerate(unique_weight): | ||||
|                     for idx_, score_ in enumerate(task_stage.__dict__[parser].weight): | ||||
|                         if score == score_: | ||||
|                             keyword_weight[idx].keywords.append( | ||||
|                                 task_stage.__dict__[parser].keyword[idx_] | ||||
|                             ) | ||||
|                         else: | ||||
|                             continue | ||||
|             else: | ||||
|                 continue | ||||
|     keyword_parser_.with_.update( | ||||
|         result.KeywordMatchConfig( | ||||
|             matches=keyword_weight, | ||||
|         ).model_dump(by_alias=True) | ||||
|     ) | ||||
| 
 | ||||
|             keyword_parser_.with_.update( | ||||
|                 result.KeywordMatchConfig( | ||||
|                     matches=keyword_weight, | ||||
|                 ).model_dump(by_alias=True) | ||||
|             ) | ||||
|     return conf_stage | ||||
| 
 | ||||
| 
 | ||||
| def fix_result_detail(task_stage: task.Stage, conf_stage: result.StageDetail) -> None: | ||||
|     if "result-detail" not in task_stage.parsers: | ||||
|         return | ||||
| def fix_result_detail( | ||||
|     task_stage: task.Stage, conf_stage: result.StageDetail, parser: str | ||||
| ) -> None: | ||||
|     result_detail_parser = next( | ||||
|         p for p in conf_stage.parsers if p.name == "result-detail" | ||||
|     ) | ||||
|  | @ -126,48 +130,40 @@ def fix_result_detail(task_stage: task.Stage, conf_stage: result.StageDetail) -> | |||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| def fix_dummy(task_stage: task.Stage, conf_stage: result.StageDetail) -> None: | ||||
|     dummy_parser = [ | ||||
|         "dummy", | ||||
|         "result-status", | ||||
|     ] | ||||
|     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 parser.replace("-", "_") not in task_stage.__dict__: | ||||
|             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) | ||||
|         ) | ||||
| def fix_dummy( | ||||
|     task_stage: task.Stage, conf_stage: result.StageDetail, parser: str | ||||
| ) -> None: | ||||
|     dummy_parser_ = next(p for p in conf_stage.parsers if p.name == parser) | ||||
|     if parser.replace("-", "_") not in task_stage.__dict__: | ||||
|         return | ||||
|     if task_stage.result_status is None: | ||||
|         return | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  When will it be None? When will it be None? | ||||
|     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 | ||||
| 
 | ||||
| 
 | ||||
| def fix_file(task_stage: task.Stage, conf_stage: result.StageDetail) -> None: | ||||
|     file_parser = ["file"] | ||||
|     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( | ||||
|             result.FileConfig(name=task_stage.file.name).model_dump(by_alias=True) | ||||
|         ) | ||||
| def fix_file( | ||||
|     task_stage: task.Stage, conf_stage: result.StageDetail, parser: str | ||||
| ) -> None: | ||||
|     file_parser_ = next(p for p in conf_stage.parsers if p.name == parser) | ||||
|     file_parser_.with_.update( | ||||
| 
					
					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.
			
			 | ||||
|         result.FileConfig(name=task_stage.file.name).model_dump(by_alias=True) | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| def fix_diff( | ||||
| 
					
					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. | ||||
|     task_stage: task.Stage, | ||||
|     task_conf: task.Config, | ||||
|     conf_stage: result.StageDetail, | ||||
|     parser: str, | ||||
| ) -> None: | ||||
|     if "diff" not in task_stage.parsers: | ||||
|         return | ||||
|     diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) | ||||
|     diff_parser = next((p for p in conf_stage.parsers if p.name == parser), None) | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  Is it necessary to rename? Is it necessary to rename? | ||||
|     skip = task_stage.skip | ||||
|     cases = task_stage.cases | ||||
|     finalized_cases = [case for case in cases if case not in skip] | ||||
|  |  | |||
|  | @ -222,11 +222,11 @@ | |||
|                                 } | ||||
|                             }, | ||||
|                             "copyInCached": { | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", | ||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan" | ||||
|                             }, | ||||
|                             "copyInDir": ".", | ||||
|                             "copyOut": [ | ||||
|  | @ -322,11 +322,11 @@ | |||
|                                 } | ||||
|                             }, | ||||
|                             "copyInCached": { | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", | ||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan" | ||||
|                             }, | ||||
|                             "copyInDir": ".", | ||||
|                             "copyOut": [ | ||||
|  | @ -444,11 +444,11 @@ | |||
|                             "cpuSetLimit": "", | ||||
|                             "copyIn": {}, | ||||
|                             "copyInCached": { | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", | ||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan" | ||||
|                             }, | ||||
|                             "copyInDir": ".", | ||||
|                             "copyOut": [ | ||||
|  | @ -467,6 +467,12 @@ | |||
|                     } | ||||
|                 }, | ||||
|                 "parsers": [ | ||||
|                     { | ||||
|                         "name": "keyword", | ||||
|                         "with": { | ||||
|                             "matches": [] | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "cppcheck", | ||||
|                         "with": { | ||||
|  | @ -489,6 +495,10 @@ | |||
|                             ] | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "clang-tidy", | ||||
|                         "with": {} | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "result-detail", | ||||
|                         "with": { | ||||
|  | @ -501,6 +511,41 @@ | |||
|                             "showRuntime": false, | ||||
|                             "showMemory": false | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "cpplint", | ||||
|                         "with": { | ||||
|                             "matches": [] | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "result-status", | ||||
|                         "with": { | ||||
|                             "score": 0, | ||||
|                             "comment": "", | ||||
|                             "forceQuitOnNotAccepted": false | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "file", | ||||
|                         "with": { | ||||
|                             "name": "" | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "dummy", | ||||
|                         "with": { | ||||
|                             "score": 0, | ||||
|                             "comment": "", | ||||
|                             "forceQuitOnNotAccepted": false | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "diff", | ||||
|                         "with": { | ||||
|                             "name": "diff", | ||||
|                             "cases": [] | ||||
|                         } | ||||
|                     } | ||||
|                 ] | ||||
|             }, | ||||
|  | @ -542,11 +587,11 @@ | |||
|                             "cpuSetLimit": "", | ||||
|                             "copyIn": {}, | ||||
|                             "copyInCached": { | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", | ||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan" | ||||
|                             }, | ||||
|                             "copyInDir": ".", | ||||
|                             "copyOut": [ | ||||
|  | @ -639,11 +684,11 @@ | |||
|                             "cpuSetLimit": "", | ||||
|                             "copyIn": {}, | ||||
|                             "copyInCached": { | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", | ||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||
|                                 "h7/build/ex2": "h7/build/ex2", | ||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan" | ||||
|                             }, | ||||
|                             "copyInDir": ".", | ||||
|                             "copyOut": [ | ||||
|  |  | |||
|  | @ -53,7 +53,7 @@ name = "[cq] Cppcheck" | |||
| command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem  --quiet h7/ex2.cpp" | ||||
| limit.stderr = "8m" | ||||
| 
 | ||||
| parsers = [ "cppcheck", "result-detail" ] | ||||
| parsers = [ "keyword", "cppcheck", "clang-tidy", "result-detail", "cpplint", "result-status", "file", "dummy", "diff" ] | ||||
| cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] | ||||
| cppcheck.weight = [15, 5, 5, 5, 5] | ||||
| result-detail.exitstatus = true | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	
should loop through
conf_stage.parsershere and update thewithfield according to the parser name.I think its already implemented in each of the
fix_parsersfunctionsNo, do not find the parser in the
fix_xxxfunction. Instead, iterate through the parsers here and decide how to fill in thewith.resolved.
Use a dict to store parser name, field, function to process.
resolved.