Files
gpu_runner/code/runner_script.py
T

30 lines
703 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')
rs = RunnerScript.model_validate( # type: ignore
{
'script': script_list
}
)
return rs
if __name__ == '__main__':
path = Path('.gitea') / 'gpu_runner' / 'script.yml'
rs = RunnerScript.from_file(path)
print(rs)