Files
gpu_runner/code/runner_script.py
T
2023-07-13 11:53:14 +02:00

25 lines
625 B
Python

from pydantic import BaseModel
from typing import List
import yaml
from pathlib import Path
import logging
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')
logging.debug('finished')
return RunnerScript.model_validate({'script': script_list})
if __name__ == '__main__':
path = Path(__file__).parent.parent / 'runner_script.yml'
rs = RunnerScript.from_file(path)
print(rs)