WIP: dev #6

Closed
李衍志523370910113 wants to merge 131 commits from dev into master
7 changed files with 11 additions and 198 deletions
Showing only changes of commit e79e66c1a7 - Show all commits

View File

@ -1,15 +1,7 @@
from typing import List
from joj3_config_generator.models import joj1, repo, result, task
from joj3_config_generator.processers.repo import getHealthcheckConfig, getTeapotConfig
from joj3_config_generator.processers.task import (
fix_dummy,
fix_diff,
fix_keyword,
fix_result_detail,
get_conf_stage,
get_executorWithConfig,
)
from joj3_config_generator.models import joj1, repo, result, task
from joj3_config_generator.processers.task import (
fix_diff,
fix_dummy,
@ -18,7 +10,6 @@ from joj3_config_generator.processers.task import (
get_conf_stage,
get_executorWithConfig,
)
from joj3_config_generator.models import joj1, repo, result, task
def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:

View File

@ -1,6 +1,7 @@
import json
import os
from pathlib import Path
from typing import Any, Dict
import inquirer
import rtoml
@ -9,8 +10,7 @@ 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.processers.task import remove_nulls
from joj3_config_generator.models import joj1, repo, result, task
from joj3_config_generator.models import joj1, repo, task
from joj3_config_generator.utils.logger import logger
app = typer.Typer(add_completion=False)
@ -47,8 +47,7 @@ def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> N
@app.command()
def convert(root: Path = Path(".")) -> result.Config:
def convert(root: Path = Path(".")) -> result.Config:
def convert(root: Path = Path(".")) -> Dict[str, Any]:
"""
Convert given dir of JOJ3 toml config files to JOJ3 json config files
"""
@ -64,13 +63,10 @@ def convert(root: Path = Path(".")) -> result.Config:
repo_obj = rtoml.loads(repo_toml)
task_obj = rtoml.loads(task_toml)
result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj))
result_model = remove_nulls(result_model)
result_dict = result_model.model_dump(by_alias=True)
result_dict = result_model.model_dump(by_alias=True, exclude_none=True)
with open(result_json_path, "w") as result_file:
json.dump(result_dict, result_file, ensure_ascii=False, indent=4)
result_file.write("\n")
return result_model
return result_model
return result_dict

View File

@ -7,7 +7,9 @@ from joj3_config_generator.models import repo, result, task
def getGradingRepoName() -> str:
host_name = socket.gethostname()
# FIXME: uncomment back when everything is ready!
host_name = "engr151"
# host_name = socket.gethostname()
return f"{host_name.split('-')[0]}-joj"

View File

@ -4,15 +4,6 @@ from typing import Tuple
from joj3_config_generator.models import result, task
def remove_nulls(d: result.Config) -> result.Config:
if isinstance(d, dict):
return {k: remove_nulls(v) for k, v in d.items() if v is not None}
elif isinstance(d, list):
return [remove_nulls(item) for item in d]
else:
return d
def get_conf_stage(
task_stage: task.Stage, executor_with_config: result.ExecutorWith
) -> result.StageDetail:

View File

@ -27,34 +27,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false

yes, remove_null function need a small adjustment

yes, `remove_null` function need a small adjustment

default value problem in pydantic model

default value problem in pydantic model
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4096,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4096,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -70,11 +58,7 @@
"copyIn": {
"./repo-health-checker": {
"src": "./repo-health-checker",
"content": null,
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -106,7 +90,6 @@
},
{
"name": "Abuse of strings detected",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -119,34 +102,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -162,11 +133,7 @@
"copyIn": {
"tools/strdetec": {
"src": "/home/tt/.config/joj/tools/strdetec",
"content": null,
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -201,7 +168,6 @@
},
{
"name": "Compilation",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -213,34 +179,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -256,11 +210,7 @@
"copyIn": {
"tools/compile": {
"src": "/home/tt/.config/joj/tools/compile",
"content": null,
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -322,7 +272,6 @@
},
{
"name": "[cq] Filelength",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -338,34 +287,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -381,11 +318,7 @@
"copyIn": {
"tools/filelength": {
"src": "/home/tt/.config/joj/tools/filelength",
"content": null,
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -452,7 +385,6 @@
},
{
"name": "[cq] Clang-tidy",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -469,34 +401,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 65000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -512,11 +432,7 @@
"copyIn": {
"projects/p2/.clang-tidy": {
"src": "/home/tt/.config/joj/projects/p2/.clang-tidy",
"content": null,
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -609,7 +525,6 @@
},
{
"name": "[cq] Cppcheck",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -627,34 +542,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 65000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -730,7 +633,6 @@
},
{
"name": "[cq] Cpplint",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -747,34 +649,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 65000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -856,7 +746,6 @@
},
{
"name": "[run] onecard",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -869,34 +758,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -950,7 +827,6 @@
},
{
"name": "[run] address sanitizer",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -963,34 +839,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -1044,7 +908,6 @@
},
{
"name": "[run] memory sanitizer",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -1057,34 +920,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -1138,7 +989,6 @@
},
{
"name": "[run] undefined behavior sanitizer",
"group": null,
"executor": {
"name": "sandbox",
"with": {
@ -1151,34 +1001,22 @@
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"src": null,
"content": "",
"fileId": null,
"name": null,
"max": 4194304,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stdout": {
"src": null,
"content": null,
"fileId": null,
"name": "stdout",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
},
"stderr": {
"src": null,
"content": null,
"fileId": null,
"name": "stderr",
"max": 4000000000,
"symlink": null,
"streamIn": false,
"streamOut": false,
"pipe": false
@ -1236,7 +1074,7 @@
"logPath": "p2-m3-joint-teapot-debug.log",
"scoreboardPath": "p2-m3-scoreboard.csv",
"failedTablePath": "p2-m3-failed-table.md",
"gradingRepoName": "Nuvole-joj",
"gradingRepoName": "engr151-joj",
"skipIssue": false,
"skipScoreboard": false,
"skipFailedTable": false

View File

@ -3,6 +3,3 @@ from tests.convert.utils import load_case
def test_basic() -> None:
load_case("basic")
test_basic()

View File

@ -7,7 +7,6 @@ import rtoml
from joj3_config_generator.convert import convert
from joj3_config_generator.models import repo, task
def read_convert_files(
case_name: str,
) -> Tuple[repo.Config, task.Config, Dict[str, Any]]:
@ -28,6 +27,5 @@ def read_convert_files(
def load_case(case_name: str) -> None:
repo, task, expected_result = read_convert_files(case_name)
result = convert(repo, task).model_dump(mode="json", by_alias=True)
result = convert(repo, task).model_dump(mode="json", by_alias=True, exclude_none=True)
assert result == expected_result