[app] starting repos with as a thread

This commit is contained in:
wendtalexander
2024-09-27 10:21:05 +02:00
parent cb5c08bc94
commit cd6bc0dc04
3 changed files with 47 additions and 12 deletions

View File

@@ -1,15 +1,34 @@
import sys
import importlib.util
import ast
import pathlib
from IPython import embed
from pyrelacs.util.logging import config_logging
log = config_logging()
class Repro:
def __init__(self) -> None:
pass
def run_repro(self, name: str, *args, **kwargs) -> None:
pass
def run_repro(self, name: str, file: pathlib.Path, *args, **kwargs) -> None:
spec = importlib.util.spec_from_file_location("rep", file)
if not spec:
log.error("Could not load the repro")
else:
module = importlib.util.module_from_spec(spec)
if not module:
log.error("Could not load Class of the repro")
else:
sys.modules[name] = module
spec.loader.exec_module(module)
if hasattr(module, name):
rep_class = getattr(module, name)
rep_class.run()
else:
raise AttributeError(f"{name} has no run function")
def names_of_repros(self):
file_path_cur = pathlib.Path(__file__).parent