added function to read runner script

This commit is contained in:
brb
2023-07-06 15:53:15 +02:00
parent 9102d03ef4
commit c1aa6f3c41
+11
View File
@@ -1,9 +1,12 @@
from pydantic import AnyHttpUrl from pydantic import AnyHttpUrl
from typing import List
from pathlib import Path from pathlib import Path
from git import Repo from git import Repo
import logging import logging
import shutil import shutil
import os import os
import yaml
from runner_script import RunnerScript
def clone_repository(repo_url: AnyHttpUrl) -> Path: def clone_repository(repo_url: AnyHttpUrl) -> Path:
# extract repo name # extract repo name
@@ -19,3 +22,11 @@ def clone_repository(repo_url: AnyHttpUrl) -> Path:
Repo.clone_from(url=repo_url, to_path=dst_dir) Repo.clone_from(url=repo_url, to_path=dst_dir)
logging.debug('finished') logging.debug('finished')
return dst_dir return dst_dir
def load_runner_script(path: Path) -> RunnerScript:
assert path.exists()
with open(path, 'r') as fh:
script = yaml.safe_load(fh)
runner_script = RunnerScript.parse_obj(script)
return runner_script