2
0
forked from awendt/pyrelacs

[app][repros] adding nix file and checks

This commit is contained in:
wendtalexander 2024-09-27 14:20:18 +02:00
parent a748385335
commit 7d3224f351

View File

@ -4,6 +4,7 @@ import ast
import pathlib
from IPython import embed
import nixio as nix
from pyrelacs.util.logging import config_logging
log = config_logging()
@ -13,22 +14,24 @@ class Repro:
def __init__(self) -> None:
pass
def run_repro(self, name: str, file: pathlib.Path, *args, **kwargs) -> None:
def run_repro(
self, nix_file: nix.File, 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")
log.error("Could not load the file")
else:
module = importlib.util.module_from_spec(spec)
if not module:
log.error("Could not load Class of the repro")
log.error("Could not load the module 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()
rep_class.run(nix_file)
else:
raise AttributeError(f"{name} has no run function")
raise AttributeError(f"{file.name} has no {name} class")
def names_of_repros(self):
file_path_cur = pathlib.Path(__file__).parent