fix(processors/task): update all with model_dump
This commit is contained in:
		
							parent
							
								
									2c4d7cede7
								
							
						
					
					
						commit
						45a184521e
					
				|  | @ -177,3 +177,26 @@ class ResultDetailConfig(BaseModel): | ||||||
|     show_exit_status: Optional[bool] = Field(True, serialization_alias="showExitStatus") |     show_exit_status: Optional[bool] = Field(True, serialization_alias="showExitStatus") | ||||||
|     show_runtime: Optional[bool] = Field(True, serialization_alias="showRuntime") |     show_runtime: Optional[bool] = Field(True, serialization_alias="showRuntime") | ||||||
|     show_memory: Optional[bool] = Field(False, serialization_alias="showMemory") |     show_memory: Optional[bool] = Field(False, serialization_alias="showMemory") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class KeywordConfig(BaseModel): | ||||||
|  |     keywords: List[str] = [] | ||||||
|  |     score: int = 0 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class KeywordMatchConfig(BaseModel): | ||||||
|  |     matches: List[KeywordConfig] = [] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class FileConfig(BaseModel): | ||||||
|  |     name: str = "" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class DiffCasesConfig(BaseModel): | ||||||
|  |     outputs: List[DiffOutputConfig] = [] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # to get minimum flexibility, may refine in future | ||||||
|  | class DiffConfig(BaseModel): | ||||||
|  |     name: str = "diff" | ||||||
|  |     cases: List[DiffCasesConfig] = [] | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import re | import re | ||||||
| import shlex | import shlex | ||||||
| from typing import Set | from typing import List, Set | ||||||
| 
 | 
 | ||||||
| from joj3_config_generator.models import result, task | from joj3_config_generator.models import result, task | ||||||
| from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT | from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT | ||||||
|  | @ -76,16 +76,18 @@ def fix_keyword( | ||||||
|     for parser in task_stage.parsers: |     for parser in task_stage.parsers: | ||||||
|         if parser in keyword_parser: |         if parser in keyword_parser: | ||||||
|             keyword_parser_ = next(p for p in conf_stage.parsers if p.name == parser) |             keyword_parser_ = next(p for p in conf_stage.parsers if p.name == parser) | ||||||
|             keyword_weight = [] |             keyword_weight: List[result.KeywordConfig] = [] | ||||||
|             if parser in task_stage.__dict__: |             if parser in task_stage.__dict__: | ||||||
|                 unique_weight = list(set(task_stage.__dict__[parser].weight)) |                 unique_weight = list(set(task_stage.__dict__[parser].weight)) | ||||||
|                 for score in unique_weight: |                 for score in unique_weight: | ||||||
|                     keyword_weight.append({"keywords": [], "score": score}) |                     keyword_weight.append( | ||||||
|  |                         result.KeywordConfig(keywords=[], score=score) | ||||||
|  |                     ) | ||||||
| 
 | 
 | ||||||
|                 for idx, score in enumerate(unique_weight): |                 for idx, score in enumerate(unique_weight): | ||||||
|                     for idx_, score_ in enumerate(task_stage.__dict__[parser].weight): |                     for idx_, score_ in enumerate(task_stage.__dict__[parser].weight): | ||||||
|                         if score == score_: |                         if score == score_: | ||||||
|                             keyword_weight[idx]["keywords"].append( |                             keyword_weight[idx].keywords.append( | ||||||
|                                 task_stage.__dict__[parser].keyword[idx_] |                                 task_stage.__dict__[parser].keyword[idx_] | ||||||
|                             ) |                             ) | ||||||
|                         else: |                         else: | ||||||
|  | @ -94,9 +96,9 @@ def fix_keyword( | ||||||
|                 continue |                 continue | ||||||
| 
 | 
 | ||||||
|             keyword_parser_.with_.update( |             keyword_parser_.with_.update( | ||||||
|                 { |                 result.KeywordMatchConfig( | ||||||
|                     "matches": keyword_weight, |                     matches=keyword_weight, | ||||||
|                 } |                 ).model_dump(by_alias=True) | ||||||
|             ) |             ) | ||||||
|     return conf_stage |     return conf_stage | ||||||
| 
 | 
 | ||||||
|  | @ -153,7 +155,9 @@ def fix_file(task_stage: task.Stage, conf_stage: result.StageDetail) -> None: | ||||||
|         if parser not in file_parser: |         if parser not in file_parser: | ||||||
|             continue |             continue | ||||||
|         file_parser_ = next(p for p in conf_stage.parsers if p.name == parser) |         file_parser_ = next(p for p in conf_stage.parsers if p.name == parser) | ||||||
|         file_parser_.with_.update({"name": task_stage.file.name}) |         file_parser_.with_.update( | ||||||
|  |             result.FileConfig(name=task_stage.file.name).model_dump(by_alias=True) | ||||||
|  |         ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def fix_diff( | def fix_diff( | ||||||
|  | @ -204,8 +208,8 @@ def fix_diff( | ||||||
|         ) |         ) | ||||||
|         if diff_output: |         if diff_output: | ||||||
|             parser_cases.append( |             parser_cases.append( | ||||||
|                 { |                 result.DiffCasesConfig( | ||||||
|                     "outputs": [ |                     outputs=[ | ||||||
|                         result.DiffOutputConfig( |                         result.DiffOutputConfig( | ||||||
|                             score=diff_output.score, |                             score=diff_output.score, | ||||||
|                             file_name="stdout", |                             file_name="stdout", | ||||||
|  | @ -215,13 +219,15 @@ def fix_diff( | ||||||
|                             force_quit_on_diff=diff_output.force_quit, |                             force_quit_on_diff=diff_output.force_quit, | ||||||
|                             always_hide=diff_output.hide, |                             always_hide=diff_output.hide, | ||||||
|                             compare_space=not diff_output.ignore_spaces, |                             compare_space=not diff_output.ignore_spaces, | ||||||
|                         ).model_dump(by_alias=True) |                         ) | ||||||
|                     ] |                     ] | ||||||
|                 } |                 ) | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|     if diff_parser: |     if diff_parser: | ||||||
|         diff_parser.with_.update({"name": "diff", "cases": parser_cases}) |         diff_parser.with_.update( | ||||||
|  |             result.DiffConfig(name="diff", cases=parser_cases).model_dump(by_alias=True) | ||||||
|  |         ) | ||||||
|         conf_stage.executor.with_.cases = stage_cases |         conf_stage.executor.with_.cases = stage_cases | ||||||
| 
 | 
 | ||||||
|     return |     return | ||||||
|  |  | ||||||
|  | @ -222,11 +222,11 @@ | ||||||
|                                 } |                                 } | ||||||
|                             }, |                             }, | ||||||
|                             "copyInCached": { |                             "copyInCached": { | ||||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", |                                 "h7/build/ex2": "h7/build/ex2", | ||||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", |  | ||||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", |                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||||
|  |                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", |                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||||
|                                 "h7/build/ex2": "h7/build/ex2" |                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||||
|                             }, |                             }, | ||||||
|                             "copyInDir": ".", |                             "copyInDir": ".", | ||||||
|                             "copyOut": [ |                             "copyOut": [ | ||||||
|  | @ -322,11 +322,11 @@ | ||||||
|                                 } |                                 } | ||||||
|                             }, |                             }, | ||||||
|                             "copyInCached": { |                             "copyInCached": { | ||||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", |                                 "h7/build/ex2": "h7/build/ex2", | ||||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", |  | ||||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", |                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||||
|  |                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", |                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||||
|                                 "h7/build/ex2": "h7/build/ex2" |                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||||
|                             }, |                             }, | ||||||
|                             "copyInDir": ".", |                             "copyInDir": ".", | ||||||
|                             "copyOut": [ |                             "copyOut": [ | ||||||
|  | @ -444,11 +444,11 @@ | ||||||
|                             "cpuSetLimit": "", |                             "cpuSetLimit": "", | ||||||
|                             "copyIn": {}, |                             "copyIn": {}, | ||||||
|                             "copyInCached": { |                             "copyInCached": { | ||||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", |                                 "h7/build/ex2": "h7/build/ex2", | ||||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", |  | ||||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", |                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||||
|  |                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", |                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||||
|                                 "h7/build/ex2": "h7/build/ex2" |                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||||
|                             }, |                             }, | ||||||
|                             "copyInDir": ".", |                             "copyInDir": ".", | ||||||
|                             "copyOut": [ |                             "copyOut": [ | ||||||
|  | @ -542,11 +542,11 @@ | ||||||
|                             "cpuSetLimit": "", |                             "cpuSetLimit": "", | ||||||
|                             "copyIn": {}, |                             "copyIn": {}, | ||||||
|                             "copyInCached": { |                             "copyInCached": { | ||||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", |                                 "h7/build/ex2": "h7/build/ex2", | ||||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", |  | ||||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", |                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||||
|  |                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", |                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||||
|                                 "h7/build/ex2": "h7/build/ex2" |                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||||
|                             }, |                             }, | ||||||
|                             "copyInDir": ".", |                             "copyInDir": ".", | ||||||
|                             "copyOut": [ |                             "copyOut": [ | ||||||
|  | @ -639,11 +639,11 @@ | ||||||
|                             "cpuSetLimit": "", |                             "cpuSetLimit": "", | ||||||
|                             "copyIn": {}, |                             "copyIn": {}, | ||||||
|                             "copyInCached": { |                             "copyInCached": { | ||||||
|                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", |                                 "h7/build/ex2": "h7/build/ex2", | ||||||
|                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json", |  | ||||||
|                                 "h7/build/ex2-asan": "h7/build/ex2-asan", |                                 "h7/build/ex2-asan": "h7/build/ex2-asan", | ||||||
|  |                                 "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", | ||||||
|                                 "h7/build/ex2-msan": "h7/build/ex2-msan", |                                 "h7/build/ex2-msan": "h7/build/ex2-msan", | ||||||
|                                 "h7/build/ex2": "h7/build/ex2" |                                 "h7/build/compile_commands.json": "h7/build/compile_commands.json" | ||||||
|                             }, |                             }, | ||||||
|                             "copyInDir": ".", |                             "copyInDir": ".", | ||||||
|                             "copyOut": [ |                             "copyOut": [ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user