RunnerManager working (dynamic creation of RUNNER_DICT)
This commit is contained in:
parent
cf3672ef4b
commit
7ac62a6e80
3 changed files with 19 additions and 19 deletions
|
|
@ -7,6 +7,7 @@ from abratest.env_manager import EnvFile, EnvManager
|
|||
from abratest.html_helper import merge_html_files
|
||||
from abratest.runner import Runner
|
||||
from abratest.runner_dict import RUNNER_DICT
|
||||
from abratest.runner_manager import RunnerManager
|
||||
from abratest.utils import rmtree
|
||||
|
||||
|
||||
|
|
@ -20,6 +21,7 @@ class Coordinator:
|
|||
|
||||
self.DIR = DirManager(output_dir=output_dir, session_id=session_id, recipes_dir=recipes_dir)
|
||||
self.ENV = EnvManager(env_paths_list)
|
||||
runner_manager = RunnerManager(recipes_dir)
|
||||
|
||||
def setup_test(self) -> None:
|
||||
logger.info("calling setup_test()")
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from dotenv import dotenv_values
|
|||
|
||||
from abratest.dir_manager import DirManager
|
||||
from abratest.runner_dict import RUNNER_DICT
|
||||
from abratest.runner_manager import RunnerManager
|
||||
|
||||
|
||||
class EnvFile(NamedTuple):
|
||||
|
|
@ -26,7 +25,6 @@ class DependencyRule(NamedTuple):
|
|||
class EnvManager:
|
||||
def __init__(self, env_paths_list: list[Path]):
|
||||
self.env_files: list[EnvFile] = self._get_env_files(env_paths_list)
|
||||
self.runner_manager = RunnerManager(self.env_files)
|
||||
self.dependency_rules: list[DependencyRule] = self._get_dependency_rules(self.env_files)
|
||||
self.env_files = self.sort_env_files_by_rule(self.env_files, self.dependency_rules)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
# should replace static RUNNER_DICT
|
||||
# WIP
|
||||
|
||||
import importlib
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from icecream import ic
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from abratest.env_manager import EnvFile, EnvManager
|
||||
from abratest.runner import Runner
|
||||
|
||||
PATTERN = re.compile("Runner.+")
|
||||
|
||||
|
||||
class RunnerManager:
|
||||
def __init__(self, env_files: list["EnvFile"]):
|
||||
pass
|
||||
def __init__(self, recipes_dir: Path):
|
||||
RUNNER_DICT_NEW = dict()
|
||||
|
||||
root = Path("src")
|
||||
ic(root.resolve())
|
||||
for module_path in root.rglob("*/runner*.py"):
|
||||
module_path = module_path.as_posix().replace("/", ".").replace(".py", "")
|
||||
ic(module_path)
|
||||
module = importlib.import_module(module_path)
|
||||
ic(dir(module))
|
||||
# exit()
|
||||
|
||||
|
||||
# ic(RUNNER_DICT)
|
||||
for module_path in recipes_dir.rglob("*/runner*.py"):
|
||||
rel_path = module_path.relative_to(recipes_dir).as_posix().replace("/", ".").replace(".py", "")
|
||||
ic(rel_path)
|
||||
module = importlib.import_module(rel_path)
|
||||
runner_class_names = [name for name in dir(module) if PATTERN.match(name)]
|
||||
assert len(runner_class_names) == 1
|
||||
runner_class_name = runner_class_names[0]
|
||||
RunnerClass: type[Runner] = getattr(module, runner_class_name)
|
||||
RUNNER_DICT_NEW[RunnerClass.name] = RunnerClass
|
||||
print(RUNNER_DICT_NEW)
|
||||
exit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue