dev #10
|  | @ -1,14 +1,9 @@ | |||
| import hashlib | ||||
| import socket | ||||
| import tempfile | ||||
| 
 | ||||
| from joj3_config_generator.models import joj1, repo, result, task | ||||
| 
 | ||||
| 
 | ||||
| def get_temp_directory() -> str: | ||||
|     return tempfile.mkdtemp(prefix="repo-checker-") | ||||
| 
 | ||||
| 
 | ||||
| def getGradingRepoName() -> str: | ||||
|     host_name = socket.gethostname() | ||||
|     return f"{host_name.split('-')[0]}-joj" | ||||
|  | @ -41,7 +36,7 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: | |||
|         else: | ||||
|             immutable_files = immutable_files + name + "," | ||||
|     # FIXME: need to make solution and make things easier to edit with global scope | ||||
|     chore = f"/{get_temp_directory}/repo-health-checker -root=. " | ||||
|     chore = f"/tmp/repo-health-checker -root=. " | ||||
|     args = "" | ||||
|     args = args + chore | ||||
|     args = args + repo_size | ||||
|  | @ -56,9 +51,7 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: | |||
|         args=args.split(), | ||||
|         # FIXME: easier to edit within global scope | ||||
|         copy_in={ | ||||
|             f"/{get_temp_directory()}/repo-health-checker": result.CmdFile( | ||||
|                 src=f"/{get_temp_directory()}/repo-health-checker" | ||||
|             ) | ||||
|             f"/tmp/repo-health-checker": result.CmdFile(src=f"/tmp/repo-health-checker") | ||||
|         }, | ||||
|     ) | ||||
|     return cmd | ||||
|  |  | |||
|  | @ -9,7 +9,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.models import joj1, repo, task | ||||
| from joj3_config_generator.models import joj1, repo, result, task | ||||
| from joj3_config_generator.utils.logger import logger | ||||
| 
 | ||||
| app = typer.Typer(add_completion=False) | ||||
|  | @ -46,7 +46,7 @@ def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> N | |||
| 
 | ||||
| 
 | ||||
| @app.command() | ||||
| def convert(root: Path = Path(".")) -> None: | ||||
| def convert(root: Path = Path(".")) -> result.Config: | ||||
|     """ | ||||
|     Convert given dir of JOJ3 toml config files to JOJ3 json config files | ||||
|     """ | ||||
|  | @ -63,7 +63,9 @@ def convert(root: Path = Path(".")) -> None: | |||
|     task_obj = rtoml.loads(task_toml) | ||||
|     result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) | ||||
|     result_dict = result_model.model_dump(by_alias=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 | ||||
|  |  | |||
|  | @ -15,10 +15,7 @@ | |||
|                     "with": { | ||||
|                         "default": { | ||||
|                             "args": [ | ||||
|                                 "/<function", | ||||
|                                 "get_temp_directory", | ||||
|                                 "at", | ||||
|                                 "0x7f8686b98180>/repo-health-checker", | ||||
|                                 "/tmp/repo-health-checker", | ||||
|                                 "-root=.", | ||||
|                                 "-repoSize=50.5", | ||||
|                                 "-meta=main.py", | ||||
|  | @ -70,8 +67,8 @@ | |||
|                             "cpuRateLimit": 0, | ||||
|                             "cpuSetLimit": "", | ||||
|                             "copyIn": { | ||||
|                                 "//tmp/repo-checker-9jj98lrm/repo-health-checker": { | ||||
|                                     "src": "//tmp/repo-checker-er4az3r2/repo-health-checker", | ||||
|                                 "/tmp/repo-health-checker": { | ||||
|                                     "src": "/tmp/repo-health-checker", | ||||
|                                     "content": null, | ||||
|                                     "fileId": null, | ||||
|                                     "name": null, | ||||
|  |  | |||
|  | @ -3,3 +3,6 @@ from tests.convert.utils import load_case | |||
| 
 | ||||
| def test_basic() -> None: | ||||
|     load_case("basic") | ||||
| 
 | ||||
| 
 | ||||
| test_basic() | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ import os | |||
| from typing import Any, Dict, Tuple | ||||
| 
 | ||||
| import rtoml | ||||
| from deepdiff import DeepDiff | ||||
| 
 | ||||
| from joj3_config_generator.convert import convert | ||||
| from joj3_config_generator.models import repo, task | ||||
|  | @ -12,13 +13,13 @@ def read_convert_files( | |||
|     case_name: str, | ||||
| ) -> Tuple[repo.Config, task.Config, Dict[str, Any]]: | ||||
|     root = os.path.dirname(os.path.realpath(__file__)) | ||||
|     repo_toml_path = os.path.join(root.absolute(), case_name, "repo.toml") | ||||
|     repo_toml_path = os.path.join(root, case_name, "repo.toml") | ||||
|     with open(repo_toml_path) as f: | ||||
|         repo_toml = f.read() | ||||
|     task_toml_path = os.path.join(root.absolute(), case_name, "task.toml") | ||||
|     task_toml_path = os.path.join(root, case_name, "task.toml") | ||||
|     with open(task_toml_path) as f: | ||||
|         task_toml = f.read() | ||||
|     result_json_path = os.path.join(root.absolute(), case_name, "task.json") | ||||
|     result_json_path = os.path.join(root, case_name, "task.json") | ||||
|     with open(result_json_path) as f: | ||||
|         result: Dict[str, Any] = json.load(f) | ||||
|     repo_obj = rtoml.loads(repo_toml) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user