# what I have done - sync main function in master branch and tested current code usage - remove redundant code - update README documents - fix the immutable files logic ## TODO - give fallback options for immutable files Co-authored-by: Boming Zhang <bomingzh@sjtu.edu.cn> Reviewed-on: #11 Co-authored-by: jon-lee <jon-lee@sjtu.edu.cn> Co-committed-by: jon-lee <jon-lee@sjtu.edu.cn>
24 lines
803 B
Python
24 lines
803 B
Python
from pathlib import Path
|
|
from typing import Any, Dict, Tuple
|
|
|
|
import rtoml
|
|
import yaml
|
|
|
|
from joj3_config_generator.convert import convert_joj1
|
|
from joj3_config_generator.models import joj1
|
|
|
|
|
|
def read_convert_joj1_files(case_name: str) -> Tuple[joj1.Config, Dict[str, Any]]:
|
|
root = Path(__file__).resolve().parent
|
|
task_yaml_path = root / case_name / "task.yaml"
|
|
task_yaml = task_yaml_path.read_text()
|
|
task_toml_path = root / case_name / "task.toml"
|
|
task_toml = task_toml_path.read_text()
|
|
return joj1.Config(**yaml.safe_load(task_yaml)), rtoml.loads(task_toml)
|
|
|
|
|
|
def load_case(case_name: str) -> None:
|
|
joj1_, expected_result = read_convert_joj1_files(case_name)
|
|
result = convert_joj1(joj1_).model_dump(by_alias=True, exclude_none=True)
|
|
assert result == expected_result
|