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