From bbda876180ecfbf3dea5f87682ff7a7188cc73f8 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 27 Nov 2024 14:51:27 +0800 Subject: [PATCH] feat: add limitation adaptation --- joj3_config_generator/main.py | 9 ++++++--- joj3_config_generator/models/repo.py | 8 ++++++-- joj3_config_generator/processers/repo.py | 22 ++++++++++++++++++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 691fcfd..de9ff47 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -73,9 +73,12 @@ def convert(root: Path = Path(".")) -> Dict[str, Any]: # FIXME: change the path to the server homework_name = "h8" # folder_path = f"/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework/{homework_name}" - folder_path = ( - "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework" - ) + # folder_path = ( + # "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework" + # ) + folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/homework/h7" + # for projects + folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/projects/p3/p3m1" assert os.path.exists(folder_path), f"there exists no {folder_path}" distribute_json(folder_path, repo_obj) return result_dict diff --git a/joj3_config_generator/models/repo.py b/joj3_config_generator/models/repo.py index 4befab6..46486c0 100644 --- a/joj3_config_generator/models/repo.py +++ b/joj3_config_generator/models/repo.py @@ -4,11 +4,13 @@ from pydantic import BaseModel, Field class Files(BaseModel): - whitelist_patterns: List[str] - whitelist_file: Optional[str] 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] @@ -16,3 +18,5 @@ class Config(BaseModel): release_tags: List[str] files: Files sandbox_token: str + max_total_score: int = Field(100) + groups : Group diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 4af04ce..8c1aec7 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -13,6 +13,22 @@ def get_grading_repo_name() -> str: 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", @@ -28,6 +44,8 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result. else "failed-table.md" ), grading_repo_name=get_grading_repo_name(), + max_total_score=repo_conf.max_total_score, + groups=groups_config ) return teapot @@ -73,7 +91,7 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: healthcheck_stage = result.StageDetail( name="healthcheck", - group=None, + group="", executor=result.Executor( name="sandbox", with_=result.ExecutorWith(default=get_healthcheck_cmd(repo_conf), cases=[]), @@ -95,7 +113,7 @@ def get_hash(immutable_files: list[str]) -> str: # input should be a list # FIXME: should be finalized when get into the server current_file_path = Path(__file__).resolve() project_root = current_file_path.parents[2] - file_path = f"{project_root}/tests/immutable_file/" + file_path = f"{project_root}/tests/immutable_p3-test/" immutable_hash = [] for i, file in enumerate(immutable_files): immutable_files[i] = file_path + file.rsplit("/", 1)[-1]