From d3f7f55b28ca95c4cf56be1c9a8d6add79e0f787 Mon Sep 17 00:00:00 2001 From: jon-lee Date: Sun, 2 Mar 2025 10:46:44 +0800 Subject: [PATCH] fix: grading repo name logic --- joj3_config_generator/models/repo.py | 1 + joj3_config_generator/processers/repo.py | 11 +- tests/convert/basic/repo.toml | 3 +- tests/convert/basic/task.json | 2 +- tests/convert/clang-tidy/task.json | 143 ++++++++++++++++++++++- tests/convert/cppcheck/task.json | 143 ++++++++++++++++++++++- tests/convert/cpplint/task.json | 143 ++++++++++++++++++++++- tests/convert/diff/task.json | 143 ++++++++++++++++++++++- tests/convert/keyword/task.json | 143 ++++++++++++++++++++++- 9 files changed, 711 insertions(+), 21 deletions(-) diff --git a/joj3_config_generator/models/repo.py b/joj3_config_generator/models/repo.py index 1014925..2a8c5ee 100644 --- a/joj3_config_generator/models/repo.py +++ b/joj3_config_generator/models/repo.py @@ -25,3 +25,4 @@ class Config(BaseModel): groups: Groups = Groups() root: Path = Path(".") path: Path = Path("repo.toml") + grading_repo_name: str = Field("") diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index cbc1d4c..e0eb9e0 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -5,18 +5,11 @@ from pathlib import Path from joj3_config_generator.models import repo, result -def get_grading_repo_name() -> str: - # FIXME: uncomment back when everything is ready! - host_name = "ece280" - # host_name = socket.gethostname() - return f"{host_name.split('-')[0]}-joj" - - def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail: args_ = "" args_ = ( args_ - + f"/usr/local/bin/joint-teapot joj3-all-env /home/tt/.config/teapot/teapot.env --grading-repo-name {get_grading_repo_name()} --max-total-score {repo_conf.max_total_score}" + + f"/usr/local/bin/joint-teapot joj3-all-env /home/tt/.config/teapot/teapot.env --grading-repo-name {repo_conf.grading_repo_name} --max-total-score {repo_conf.max_total_score}" ) stage_conf = result.StageDetail( @@ -69,7 +62,7 @@ def get_debug_args(repo_conf: repo.Config) -> str: args = "" args = ( args - + f"/usr/local/bin/joint-teapot joj3-check-env /home/tt/.config/teapot/teapot.env --grading-repo-name {get_grading_repo_name()} --group-config " + + f"/usr/local/bin/joint-teapot joj3-check-env /home/tt/.config/teapot/teapot.env --grading-repo-name {repo_conf.grading_repo_name} --group-config " ) group_config = "" for i, name in enumerate(repo_conf.groups.name): diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index 9ec742d..3d13343 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -1,5 +1,6 @@ -sandbox_token = "test" +grading_repo_name = "ece280-joj" +sandbox_token = "test" # reconfigure later max_total_score = 100 max_size = 50.5 diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 61a8a4c..ad1ead4 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,7 +1,7 @@ { "name": "hw7 ex2", "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", - "expireUnixTimestamp": 1735574399, + "expireUnixTimestamp": -1, "effectiveUnixTimestamp": -1, "actorCsvPath": "/home/tt/.config/joj/students.csv", "maxTotalScore": 100, diff --git a/tests/convert/clang-tidy/task.json b/tests/convert/clang-tidy/task.json index 9d47190..d05ca4b 100644 --- a/tests/convert/clang-tidy/task.json +++ b/tests/convert/clang-tidy/task.json @@ -1,7 +1,7 @@ { "name": "hw7 ex2", "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", - "expireUnixTimestamp": 1735574399, + "expireUnixTimestamp": -1, "effectiveUnixTimestamp": -1, "actorCsvPath": "/home/tt/.config/joj/students.csv", "maxTotalScore": 100, @@ -10,6 +10,91 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "env": [], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": [ + "/usr/local/bin/repo-health-checker", + "-root=.", + "-repoSize=10", + "-checkFileSumList=-checkFileNameList=" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-check-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--group-config", + "=100:24" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 1 + } + }, + { + "name": "debug", + "with": { + "score": 0 + } + } + ] + }, { "name": "[cq] Clang-tidy", "group": "cq", @@ -142,6 +227,60 @@ } ], "preStages": [], - "postStages": [] + "postStages": [ + { + "name": "teapot", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-all-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--max-total-score", + "100" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "log", + "with": { + "msg": "joj3 summary" + } + } + ] + } + ] } } diff --git a/tests/convert/cppcheck/task.json b/tests/convert/cppcheck/task.json index 2531d29..b6af69b 100644 --- a/tests/convert/cppcheck/task.json +++ b/tests/convert/cppcheck/task.json @@ -1,7 +1,7 @@ { "name": "hw7 ex2", "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", - "expireUnixTimestamp": 1735574399, + "expireUnixTimestamp": -1, "effectiveUnixTimestamp": -1, "actorCsvPath": "/home/tt/.config/joj/students.csv", "maxTotalScore": 100, @@ -10,6 +10,91 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "env": [], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": [ + "/usr/local/bin/repo-health-checker", + "-root=.", + "-repoSize=10", + "-checkFileSumList=-checkFileNameList=" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-check-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--group-config", + "=100:24" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 1 + } + }, + { + "name": "debug", + "with": { + "score": 0 + } + } + ] + }, { "name": "[cq] Cppcheck", "group": "cq", @@ -112,6 +197,60 @@ } ], "preStages": [], - "postStages": [] + "postStages": [ + { + "name": "teapot", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-all-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--max-total-score", + "100" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "log", + "with": { + "msg": "joj3 summary" + } + } + ] + } + ] } } diff --git a/tests/convert/cpplint/task.json b/tests/convert/cpplint/task.json index 3beef8e..c16ec60 100644 --- a/tests/convert/cpplint/task.json +++ b/tests/convert/cpplint/task.json @@ -1,7 +1,7 @@ { "name": "hw7 ex2", "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", - "expireUnixTimestamp": 1735574399, + "expireUnixTimestamp": -1, "effectiveUnixTimestamp": -1, "actorCsvPath": "/home/tt/.config/joj/students.csv", "maxTotalScore": 100, @@ -10,6 +10,91 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "env": [], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": [ + "/usr/local/bin/repo-health-checker", + "-root=.", + "-repoSize=10", + "-checkFileSumList=-checkFileNameList=" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-check-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--group-config", + "=100:24" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 1 + } + }, + { + "name": "debug", + "with": { + "score": 0 + } + } + ] + }, { "name": "[cq] Cpplint", "group": "cq", @@ -114,6 +199,60 @@ } ], "preStages": [], - "postStages": [] + "postStages": [ + { + "name": "teapot", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-all-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--max-total-score", + "100" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "log", + "with": { + "msg": "joj3 summary" + } + } + ] + } + ] } } diff --git a/tests/convert/diff/task.json b/tests/convert/diff/task.json index 30651fa..14b70c2 100644 --- a/tests/convert/diff/task.json +++ b/tests/convert/diff/task.json @@ -1,7 +1,7 @@ { "name": "hw7 ex2", "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", - "expireUnixTimestamp": 1735574399, + "expireUnixTimestamp": -1, "effectiveUnixTimestamp": -1, "actorCsvPath": "/home/tt/.config/joj/students.csv", "maxTotalScore": 100, @@ -10,6 +10,91 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "env": [], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": [ + "/usr/local/bin/repo-health-checker", + "-root=.", + "-repoSize=10", + "-checkFileSumList=-checkFileNameList=" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-check-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--group-config", + "=100:24" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 1 + } + }, + { + "name": "debug", + "with": { + "score": 0 + } + } + ] + }, { "name": "[joj] ex2-asan", "group": "joj", @@ -139,6 +224,60 @@ } ], "preStages": [], - "postStages": [] + "postStages": [ + { + "name": "teapot", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-all-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--max-total-score", + "100" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "log", + "with": { + "msg": "joj3 summary" + } + } + ] + } + ] } } diff --git a/tests/convert/keyword/task.json b/tests/convert/keyword/task.json index f1f1327..8fdd3cb 100644 --- a/tests/convert/keyword/task.json +++ b/tests/convert/keyword/task.json @@ -1,7 +1,7 @@ { "name": "hw7 ex2", "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", - "expireUnixTimestamp": 1735574399, + "expireUnixTimestamp": -1, "effectiveUnixTimestamp": -1, "actorCsvPath": "/home/tt/.config/joj/students.csv", "maxTotalScore": 100, @@ -10,6 +10,91 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "env": [], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": [ + "/usr/local/bin/repo-health-checker", + "-root=.", + "-repoSize=10", + "-checkFileSumList=-checkFileNameList=" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-check-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--group-config", + "=100:24" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "clockLimit": 2, + "memoryLimit": 128000000, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 1 + } + }, + { + "name": "debug", + "with": { + "score": 0 + } + } + ] + }, { "name": "[cq] Filelength", "group": "cq", @@ -111,6 +196,60 @@ } ], "preStages": [], - "postStages": [] + "postStages": [ + { + "name": "teapot", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-all-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "--max-total-score", + "100" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "cpuLimit": 0, + "realCpuLimit": 0, + "clockLimit": 2, + "memoryLimit": 128000000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "log", + "with": { + "msg": "joj3 summary" + } + } + ] + } + ] } }