diff --git a/code/runner_script.py b/code/runner_script.py index 2fd6c55..447a5ee 100644 --- a/code/runner_script.py +++ b/code/runner_script.py @@ -7,10 +7,16 @@ from pathlib import Path class RunnerScript(BaseModel): script: List[str] + @staticmethod + def from_file(path: Path): + assert path.exists() + with open(path, 'r') as fh: + content_dict = yaml.safe_load(fh) + script_list = content_dict['script'].split('\n') + return RunnerScript.model_validate({'script': script_list}) + if __name__ == '__main__': path = Path(__file__).parent.parent / 'runner_script.yml' - with open(path, 'r') as fh: - script = yaml.safe_load(fh) - runner_script = RunnerScript.parse_obj(script) - print(runner_script) \ No newline at end of file + rs = RunnerScript.from_file(path) + print(rs) \ No newline at end of file