25 lines
641 B
Python
25 lines
641 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}) # type: ignore
|
|
|
|
|
|
if __name__ == '__main__':
|
|
path = Path(__file__).parent.parent / 'runner_script.yml'
|
|
rs = RunnerScript.from_file(path)
|
|
print(rs)
|