feat: teapot stage added
This commit is contained in:
		
							parent
							
								
									1c48d9794b
								
							
						
					
					
						commit
						47c46755e6
					
				|  | @ -8,12 +8,13 @@ from joj3_config_generator.models import joj1, repo, result, task | |||
| from joj3_config_generator.processers.repo import ( | ||||
|     get_healthcheck_config, | ||||
|     get_teapot_config, | ||||
|     get_teapotcheck_config, | ||||
| ) | ||||
| from joj3_config_generator.processers.task import ( | ||||
|     fix_diff, | ||||
|     fix_dummy, | ||||
|     fix_keyword, | ||||
|     fix_file, | ||||
|     fix_keyword, | ||||
|     fix_result_detail, | ||||
|     get_conf_stage, | ||||
|     get_executorWithConfig, | ||||
|  | @ -39,6 +40,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: | |||
| 
 | ||||
|     # Construct healthcheck stage | ||||
|     healthcheck_stage = get_healthcheck_config(repo_conf) | ||||
|     teapotcheck_stage = get_teapotcheck_config(repo_conf, task_conf) | ||||
|     result_conf.stage.stages.append(healthcheck_stage) | ||||
|     cached: List[str] = [] | ||||
|     # Convert each stage in the task configuration | ||||
|  |  | |||
|  | @ -10,7 +10,6 @@ import yaml | |||
| 
 | ||||
| from joj3_config_generator.convert import convert as convert_conf | ||||
| from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf | ||||
| from joj3_config_generator.convert import distribute_json | ||||
| from joj3_config_generator.models import joj1, repo, task | ||||
| from joj3_config_generator.utils.logger import logger | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| from typing import List, Optional | ||||
| from typing import List | ||||
| 
 | ||||
| from pydantic import BaseModel, Field | ||||
| 
 | ||||
|  | @ -7,11 +7,13 @@ class Files(BaseModel): | |||
|     required: List[str] | ||||
|     immutable: List[str] | ||||
| 
 | ||||
| 
 | ||||
| class Group(BaseModel): | ||||
|     name: List[str] | ||||
|     max_count: List[int] | ||||
|     time_period_hour: List[int] | ||||
| 
 | ||||
| 
 | ||||
| class Config(BaseModel): | ||||
|     teaching_team: List[str] | ||||
|     max_size: float = Field(..., ge=0) | ||||
|  |  | |||
|  | @ -33,7 +33,7 @@ class Cmd(BaseModel): | |||
|     copy_in: Dict[str, CmdFile] = Field({}, serialization_alias="copyIn") | ||||
|     copy_in_cached: Dict[str, str] = Field({}, serialization_alias="copyInCached") | ||||
|     copy_in_dir: str = Field(".", serialization_alias="copyInDir") | ||||
|     copy_out: List[str] = Field([], serialization_alias="copyOut") | ||||
|     copy_out: List[str] = Field(["stdout", "stderr"], serialization_alias="copyOut") | ||||
|     copy_out_cached: List[str] = Field([], serialization_alias="copyOutCached") | ||||
|     copy_out_max: int = Field(0, serialization_alias="copyOutMax") | ||||
|     copy_out_dir: str = Field("", serialization_alias="copyOutDir") | ||||
|  | @ -68,7 +68,9 @@ class OptionalCmd(BaseModel): | |||
|         None, serialization_alias="copyInCached" | ||||
|     ) | ||||
|     copy_in_dir: Optional[str] = Field(None, serialization_alias="copyInDir") | ||||
|     copy_out: Optional[List[str]] = Field(None, serialization_alias="copyOut") | ||||
|     copy_out: Optional[List[str]] = Field( | ||||
|         ["stdout", "stderr"], serialization_alias="copyOut" | ||||
|     ) | ||||
|     copy_out_cached: Optional[List[str]] = Field( | ||||
|         None, serialization_alias="copyOutCached" | ||||
|     ) | ||||
|  | @ -139,7 +141,9 @@ class Teapot(BaseModel): | |||
|     skip_scoreboard: bool = Field(False, serialization_alias="skipScoreboard") | ||||
|     skip_failed_table: bool = Field(False, serialization_alias="skipFailedTable") | ||||
|     max_total_score: int = Field(100, serialization_alias="maxTotalScore") | ||||
|     groups: List[Dict[str, Any]] = Field([{"name": "", "maxCount": 100, "timePeriodHour": 24}]) | ||||
|     groups: List[Dict[str, Any]] = Field( | ||||
|         [{"name": "", "maxCount": 100, "timePeriodHour": 24}] | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| class Config(BaseModel): | ||||
|  |  | |||
|  | @ -11,9 +11,11 @@ class ParserResultDetail(BaseModel): | |||
|     stderr: Optional[bool] = False  # Display stderr messages | ||||
|     exitstatus: Optional[bool] = False | ||||
| 
 | ||||
| 
 | ||||
| class ParserFile(BaseModel): | ||||
|     name: str = None | ||||
| 
 | ||||
| 
 | ||||
| class ParserDummy(BaseModel): | ||||
|     comment: Optional[str] = "" | ||||
|     score: Optional[int] = 0 | ||||
|  |  | |||
|  | @ -45,7 +45,7 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result. | |||
|         ), | ||||
|         grading_repo_name=get_grading_repo_name(), | ||||
|         max_total_score=repo_conf.max_total_score, | ||||
|         groups=groups_config | ||||
|         groups=groups_config, | ||||
|     ) | ||||
|     return teapot | ||||
| 
 | ||||
|  | @ -88,6 +88,16 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: | |||
|     return cmd | ||||
| 
 | ||||
| 
 | ||||
| def get_teapotcheck_cmd(repo_conf: repo.Config, task_conf: task.Config) -> result.Cmd: | ||||
|     return 0 | ||||
| 
 | ||||
| 
 | ||||
| def get_teapotcheck_config( | ||||
|     repo_conf: repo.Config, task_conf: task.Config | ||||
| ) -> result.StageDetail: | ||||
|     return 0 | ||||
| 
 | ||||
| 
 | ||||
| def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: | ||||
|     healthcheck_stage = result.StageDetail( | ||||
|         name="healthcheck", | ||||
|  |  | |||
|  | @ -1,5 +1,4 @@ | |||
| import shlex | ||||
| import re | ||||
| from typing import List, Tuple | ||||
| 
 | ||||
| from joj3_config_generator.models import result, task | ||||
|  | @ -16,11 +15,7 @@ def get_conf_stage( | |||
|         #     if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) | ||||
|         #     else "" | ||||
|         # ), | ||||
|         group=( | ||||
|             task_stage.group | ||||
|             if (task_stage.group is not None) | ||||
|             else "" | ||||
|         ), | ||||
|         group=(task_stage.group if (task_stage.group is not None) else ""), | ||||
|         executor=result.Executor( | ||||
|             name="sandbox", | ||||
|             with_=executor_with_config, | ||||
|  | @ -149,7 +144,14 @@ def fix_keyword( | |||
|                             else: | ||||
|                                 continue | ||||
| 
 | ||||
|                 keyword_parser_.with_.update({"matches": keyword_weight, "fullscore": 0, "minscore": -1000, "files": ["stdout", "stderr"]}) | ||||
|                 keyword_parser_.with_.update( | ||||
|                     { | ||||
|                         "matches": keyword_weight, | ||||
|                         "fullscore": 0, | ||||
|                         "minscore": -1000, | ||||
|                         "files": ["stdout", "stderr"], | ||||
|                     } | ||||
|                 ) | ||||
|             else: | ||||
|                 continue | ||||
|     return conf_stage | ||||
|  | @ -213,22 +215,22 @@ def fix_dummy( | |||
|                 continue | ||||
|     return conf_stage | ||||
| 
 | ||||
| def fix_file(task_stage: task.Stage, conf_stage: result.StageDetail) -> result.StageDetail: | ||||
| 
 | ||||
| def fix_file( | ||||
|     task_stage: task.Stage, conf_stage: result.StageDetail | ||||
| ) -> result.StageDetail: | ||||
|     file_parser = ["file"] | ||||
|     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 | ||||
|                         } | ||||
|                     ) | ||||
|                     file_parser_.with_.update({"name": task_stage.file.name}) | ||||
|             else: | ||||
|                 continue | ||||
|     return conf_stage | ||||
| 
 | ||||
| 
 | ||||
| def fix_diff( | ||||
|     task_stage: task.Stage, conf_stage: result.StageDetail, task_conf: task.Config | ||||
| ) -> result.StageDetail: | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user