This commit is contained in:
		
							parent
							
								
									6630612915
								
							
						
					
					
						commit
						ce4605a22a
					
				|  | @ -1,5 +0,0 @@ | ||||||
| from joj3_config_generator.models import answer, task |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def create(answers: answer.Answers) -> task.Config: |  | ||||||
|     return task.Config(task=task.Task(name=answers.name, type_=answers.type_)) |  | ||||||
|  | @ -1,16 +1,26 @@ | ||||||
| import os | import os | ||||||
| from typing import Dict | from typing import Dict | ||||||
| 
 | 
 | ||||||
| from joj3_config_generator.models import joj1, repo, result, task | from joj3_config_generator.models import answer, joj1, repo, result, task | ||||||
| from joj3_config_generator.models.const import CACHE_ROOT, JOJ3_CONFIG_ROOT | from joj3_config_generator.models.const import CACHE_ROOT, JOJ3_CONFIG_ROOT | ||||||
| from joj3_config_generator.processers.repo import ( | from joj3_config_generator.transformers.repo import ( | ||||||
|     get_health_check_stage, |     get_health_check_stage, | ||||||
|     get_teapot_stage, |     get_teapot_stage, | ||||||
| ) | ) | ||||||
| from joj3_config_generator.processers.task import get_conf_stage | from joj3_config_generator.transformers.task import get_conf_stage | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: | # TODO: implement | ||||||
|  | def create_joj3_task_conf(answers: answer.Answers) -> task.Config: | ||||||
|  |     return task.Config(task=task.Task(name=answers.name, type_=answers.type_)) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # TODO: implement | ||||||
|  | def convert_joj1_conf(joj1_conf: joj1.Config) -> task.Config: | ||||||
|  |     return task.Config() | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def convert_joj3_conf(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: | ||||||
|     # Create the base ResultConf object |     # Create the base ResultConf object | ||||||
|     result_conf = result.Config( |     result_conf = result.Config( | ||||||
|         name=task_conf.task.name, |         name=task_conf.task.name, | ||||||
|  | @ -35,7 +45,3 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: | ||||||
|         result_conf.stage.post_stages.append(get_teapot_stage(repo_conf)) |         result_conf.stage.post_stages.append(get_teapot_stage(repo_conf)) | ||||||
| 
 | 
 | ||||||
|     return result_conf |     return result_conf | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def convert_joj1(joj1_conf: joj1.Config) -> task.Config: |  | ||||||
|     return task.Config() |  | ||||||
|  | @ -6,10 +6,12 @@ import rtoml | ||||||
| import typer | import typer | ||||||
| from typing_extensions import Annotated | from typing_extensions import Annotated | ||||||
| 
 | 
 | ||||||
| from joj3_config_generator.convert import convert as convert_conf | from joj3_config_generator.generator import ( | ||||||
| from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf |     convert_joj1_conf, | ||||||
| from joj3_config_generator.create import create as create_joj3_task_conf |     convert_joj3_conf, | ||||||
| from joj3_config_generator.load import ( |     create_joj3_task_conf, | ||||||
|  | ) | ||||||
|  | from joj3_config_generator.loader import ( | ||||||
|     load_joj1_yaml, |     load_joj1_yaml, | ||||||
|     load_joj3_task_toml_answers, |     load_joj3_task_toml_answers, | ||||||
|     load_joj3_toml, |     load_joj3_toml, | ||||||
|  | @ -78,7 +80,7 @@ def convert( | ||||||
|                 f"Converting {repo_toml_path} & {task_toml_path} to {result_json_path}" |                 f"Converting {repo_toml_path} & {task_toml_path} to {result_json_path}" | ||||||
|             ) |             ) | ||||||
|             repo_conf, task_conf = load_joj3_toml(root, repo_toml_path, task_toml_path) |             repo_conf, task_conf = load_joj3_toml(root, repo_toml_path, task_toml_path) | ||||||
|             result_model = convert_conf(repo_conf, task_conf) |             result_model = convert_joj3_conf(repo_conf, task_conf) | ||||||
|             result_dict = result_model.model_dump( |             result_dict = result_model.model_dump( | ||||||
|                 mode="json", by_alias=True, exclude_none=True |                 mode="json", by_alias=True, exclude_none=True | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| import json | import json | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| 
 | 
 | ||||||
| from joj3_config_generator.convert import convert | from joj3_config_generator.generator import convert_joj3_conf | ||||||
| from joj3_config_generator.load import load_joj3_toml | from joj3_config_generator.loader import load_joj3_toml | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def load_case(case_name: str) -> None: | def load_case(case_name: str) -> None: | ||||||
|  | @ -12,7 +12,7 @@ def load_case(case_name: str) -> None: | ||||||
|     repo_conf, task_conf = load_joj3_toml(root, repo_toml_path, task_toml_path) |     repo_conf, task_conf = load_joj3_toml(root, repo_toml_path, task_toml_path) | ||||||
|     result_json_path = root / case_name / "task.json" |     result_json_path = root / case_name / "task.json" | ||||||
|     expected_result = json.loads(result_json_path.read_text()) |     expected_result = json.loads(result_json_path.read_text()) | ||||||
|     result = convert(repo_conf, task_conf).model_dump( |     result = convert_joj3_conf(repo_conf, task_conf).model_dump( | ||||||
|         mode="json", by_alias=True, exclude_none=True |         mode="json", by_alias=True, exclude_none=True | ||||||
|     ) |     ) | ||||||
|     assert result == expected_result |     assert result == expected_result | ||||||
|  |  | ||||||
|  | @ -2,8 +2,8 @@ from pathlib import Path | ||||||
| 
 | 
 | ||||||
| import rtoml | import rtoml | ||||||
| 
 | 
 | ||||||
| from joj3_config_generator.convert import convert_joj1 | from joj3_config_generator.generator import convert_joj1_conf | ||||||
| from joj3_config_generator.load import load_joj1_yaml | from joj3_config_generator.loader import load_joj1_yaml | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def load_case(case_name: str) -> None: | def load_case(case_name: str) -> None: | ||||||
|  | @ -13,7 +13,7 @@ def load_case(case_name: str) -> None: | ||||||
|     task_toml_path = root / case_name / "task.toml" |     task_toml_path = root / case_name / "task.toml" | ||||||
|     task_toml = task_toml_path.read_text() |     task_toml = task_toml_path.read_text() | ||||||
|     expected_result = rtoml.loads(task_toml) |     expected_result = rtoml.loads(task_toml) | ||||||
|     result = convert_joj1(task_yaml).model_dump( |     result = convert_joj1_conf(task_yaml).model_dump( | ||||||
|         mode="json", by_alias=True, exclude_none=True |         mode="json", by_alias=True, exclude_none=True | ||||||
|     ) |     ) | ||||||
|     assert result == expected_result |     assert result == expected_result | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ from pathlib import Path | ||||||
| 
 | 
 | ||||||
| import rtoml | import rtoml | ||||||
| 
 | 
 | ||||||
| from joj3_config_generator.create import create | from joj3_config_generator.generator import create_joj3_task_conf | ||||||
| from joj3_config_generator.models import answer | from joj3_config_generator.models import answer | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -14,7 +14,7 @@ def load_case(case_name: str) -> None: | ||||||
|     answers = answer.Answers(**json.loads(answers_json_path.read_text())) |     answers = answer.Answers(**json.loads(answers_json_path.read_text())) | ||||||
|     print(answers) |     print(answers) | ||||||
|     expected_result = rtoml.loads(task_toml_path.read_text()) |     expected_result = rtoml.loads(task_toml_path.read_text()) | ||||||
|     result = create(answers).model_dump( |     result = create_joj3_task_conf(answers).model_dump( | ||||||
|         mode="json", by_alias=True, exclude_none=True, exclude_unset=True |         mode="json", by_alias=True, exclude_none=True, exclude_unset=True | ||||||
|     ) |     ) | ||||||
|     print(result) |     print(result) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user