dev #10
|  | @ -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) | ||||
|  | @ -19,4 +21,4 @@ class Config(BaseModel): | |||
|     files: Files | ||||
|     sandbox_token: str | ||||
|     max_total_score: int = Field(100) | ||||
|     groups : Group | ||||
|     groups: Group | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -22,13 +22,13 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result. | |||
|                 "timePeriodHour": 24, | ||||
|             } | ||||
|         ) | ||||
|      | ||||
| 
 | ||||
|     for idx, max_count in enumerate(repo_conf.groups.max_count): | ||||
|         groups_config[idx]["maxCount"] = max_count | ||||
|      | ||||
| 
 | ||||
|     for idx, time_period_hour in enumerate(repo_conf.groups.time_period_hour): | ||||
|         groups_config[idx]["timePeriodHour"] = time_period_hour | ||||
|      | ||||
| 
 | ||||
|     teapot = result.Teapot( | ||||
|         # TODO: fix the log path | ||||
|         log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}-joint-teapot-debug.log", | ||||
|  | @ -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 | ||||
| 
					
					jon-lee marked this conversation as resolved
					
				 | ||||
| import re | ||||
| from typing import List, Tuple | ||||
| 
					
					jon-lee marked this conversation as resolved
					
				 
				
					
						张泊明518370910136
						commented  Some  Some `with_.update` is still using raw dict, not model with `model_dump`. | ||||
| 
 | ||||
| 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 "" | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						李衍志523370910113
						commented  BTW, is this outdated? BTW, is this outdated? 
				
					
						张泊明518370910136
						commented  Never heard about this rule. Never heard about this rule. 
				
					
						李衍志523370910113
						commented  @manuel what would be the current intended rule for  @manuel what would be the current intended rule for `group`? 
				
					
						李衍志523370910113
						commented  seems current strategy is fine, resolved. seems current strategy is fine, resolved. | ||||
|         # ), | ||||
|         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: | ||||
| 
					
					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.
			
			 | ||||
|                 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: | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  When will it be None? When will it be 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: | ||||
| 
					
					jon-lee marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  Just pass  Just pass `conf_stage.executor` to this function rather then the whole `conf_stage`. | ||||
|                     file_parser_.with_.update( | ||||
|                         { | ||||
|                             "name": task_stage.file.name | ||||
|                         } | ||||
|                     ) | ||||
|                     file_parser_.with_.update({"name": task_stage.file.name}) | ||||
|             else: | ||||
|                 continue | ||||
|     return  conf_stage | ||||
|              | ||||
|     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
	
Path should not be relative to
JOJ3_CONFIG_ROOTin this file, should be relative totask.tomldirI reckon you said things is relative to
JOJ3_CONFIG_ROOTin JTC before. we have atask.typeintask.tomlto mend the pathconfig.pathis relative toJOJ3_CONFIG_ROOT.could you explain further? I m not quite sure my understanding is clear.
In
joj3_config_generator/models/task.py,Config.pathis relative toJOJ3_CONFIG_ROOT, sotask.tomlwill located atJOJ3_CONFIG_ROOT / task_conf.pathin JTC.