refactor: remove redundant teapot config code
This commit is contained in:
		
							parent
							
								
									9f3d820ae3
								
							
						
					
					
						commit
						84e6f67f83
					
				|  | @ -7,7 +7,6 @@ import rtoml | ||||||
| from joj3_config_generator.models import joj1, repo, result, task | from joj3_config_generator.models import joj1, repo, result, task | ||||||
| from joj3_config_generator.processers.repo import (  # get_teapotcheck_config, | from joj3_config_generator.processers.repo import (  # get_teapotcheck_config, | ||||||
|     get_healthcheck_config, |     get_healthcheck_config, | ||||||
|     get_teapot_config, |  | ||||||
|     get_teapot_stage, |     get_teapot_stage, | ||||||
| ) | ) | ||||||
| from joj3_config_generator.processers.task import ( | from joj3_config_generator.processers.task import ( | ||||||
|  | @ -39,7 +38,6 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: | ||||||
|             sandbox_token=repo_conf.sandbox_token, |             sandbox_token=repo_conf.sandbox_token, | ||||||
|             poststages=[get_teapot_stage(repo_conf)], |             poststages=[get_teapot_stage(repo_conf)], | ||||||
|         ), |         ), | ||||||
|         teapot=get_teapot_config(repo_conf, task_conf), |  | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     # Construct healthcheck stage |     # Construct healthcheck stage | ||||||
|  |  | ||||||
|  | @ -121,29 +121,10 @@ class Stage(BaseModel): | ||||||
|     poststages: List[StageDetail] |     poststages: List[StageDetail] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Teapot(BaseModel): |  | ||||||
|     log_path: str = Field( |  | ||||||
|         "/home/tt/.cache/joint-teapot-debug.log", serialization_alias="logPath" |  | ||||||
|     ) |  | ||||||
|     scoreboard_path: str = Field("scoreboard.csv", serialization_alias="scoreboardPath") |  | ||||||
|     failed_table_path: str = Field( |  | ||||||
|         "failed-table.md", serialization_alias="failedTablePath" |  | ||||||
|     ) |  | ||||||
|     grading_repo_name: str = Field("", serialization_alias="gradingRepoName") |  | ||||||
|     skip_issue: bool = Field(False, serialization_alias="skipIssue") |  | ||||||
|     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}] |  | ||||||
|     ) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| class Config(BaseModel): | class Config(BaseModel): | ||||||
|     name: str = "" |     name: str = "" | ||||||
|     log_path: str = Field("", serialization_alias="logPath") |     log_path: str = Field("", serialization_alias="logPath") | ||||||
|     expire_unix_timestamp: int = Field(-1, serialization_alias="expireUnixTimestamp") |     expire_unix_timestamp: int = Field(-1, serialization_alias="expireUnixTimestamp") | ||||||
|     actor_csv_path: str = Field("", serialization_alias="actorpostStagesCsvPath") |     actor_csv_path: str = Field("", serialization_alias="actorCsvPath") | ||||||
|     max_total_score: int = Field(100, serialization_alias="maxTotalScore") |     max_total_score: int = Field(100, serialization_alias="maxTotalScore") | ||||||
|     stage: Stage |     stage: Stage | ||||||
|     teapot: Teapot  # FIXME: remove this |  | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ import shlex | ||||||
| import socket | import socket | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| 
 | 
 | ||||||
| from joj3_config_generator.models import repo, result, task | from joj3_config_generator.models import repo, result | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def get_grading_repo_name() -> str: | def get_grading_repo_name() -> str: | ||||||
|  | @ -13,44 +13,6 @@ def get_grading_repo_name() -> str: | ||||||
|     return f"{host_name.split('-')[0]}-joj" |     return f"{host_name.split('-')[0]}-joj" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: |  | ||||||
|     groups_config = [] |  | ||||||
|     for group_name in repo_conf.groups.name: |  | ||||||
|         groups_config.append( |  | ||||||
|             { |  | ||||||
|                 "name": group_name, |  | ||||||
|                 "maxCount": 1000, |  | ||||||
|                 "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", |  | ||||||
|         # FIXME: may need to fix the path below |  | ||||||
|         scoreboard_path=( |  | ||||||
|             f"{task_conf.task.type_.split("/")[0]}/{task_conf.task.type_.split("/")[1]}-scoreboard.csv" |  | ||||||
|             if task_conf.task.type_ is not None |  | ||||||
|             else "scoreboard.csv" |  | ||||||
|         ), |  | ||||||
|         failed_table_path=( |  | ||||||
|             f"{task_conf.task.type_.split("/")[0]}/{task_conf.task.type_.split("/")[1]}-failed-table.md" |  | ||||||
|             if task_conf.task.type_ is not None |  | ||||||
|             else "failed-table.md" |  | ||||||
|         ), |  | ||||||
|         grading_repo_name=get_grading_repo_name(), |  | ||||||
|         max_total_score=repo_conf.max_total_score, |  | ||||||
|         groups=groups_config, |  | ||||||
|     ) |  | ||||||
|     return teapot |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail: | def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail: | ||||||
|     args_ = "" |     args_ = "" | ||||||
|     args_ = ( |     args_ = ( | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ def get_conf_stage( | ||||||
| ) -> result.StageDetail: | ) -> result.StageDetail: | ||||||
|     conf_stage = result.StageDetail( |     conf_stage = result.StageDetail( | ||||||
|         name=task_stage.name if task_stage.name is not None else "", |         name=task_stage.name if task_stage.name is not None else "", | ||||||
|         # FIXME: to be deterined the way |         # FIXME: to be deterined the way | ||||||
|         # group=( |         # group=( | ||||||
|         #     re.search(r'\[([^\[\]]+)\]', task_stage.name).group(1) |         #     re.search(r'\[([^\[\]]+)\]', task_stage.name).group(1) | ||||||
|         #     if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) |         #     if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ | ||||||
|     "name": "hw7 ex2", |     "name": "hw7 ex2", | ||||||
|     "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", |     "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", | ||||||
|     "expireUnixTimestamp": 1735574399, |     "expireUnixTimestamp": 1735574399, | ||||||
|     "actorpostStagesCsvPath": "/home/tt/.config/joj/students.csv", |     "actorCsvPath": "/home/tt/.config/joj/students.csv", | ||||||
|     "maxTotalScore": 100, |     "maxTotalScore": 100, | ||||||
|     "stage": { |     "stage": { | ||||||
|         "sandboxExecServer": "172.17.0.1:5051", |         "sandboxExecServer": "172.17.0.1:5051", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user