From c7c73fad20dc47fbccbf652d41bd3d04f95ab2f1 Mon Sep 17 00:00:00 2001 From: james <81617086+je-cook@users.noreply.github.com> Date: Mon, 5 Feb 2024 08:30:17 +0000 Subject: [PATCH] WIP injection of model into run, unify SingleRun and VaryRun run --- process/main.py | 10 ++++------ tests/unit/test_main.py | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/process/main.py b/process/main.py index 235e13c6a..ad766c609 100644 --- a/process/main.py +++ b/process/main.py @@ -201,7 +201,7 @@ def run_mode(self): self.run = VaryRun(self.args.varyiterparamsconfig, self.args.solver) else: self.run = SingleRun(self.args.input, self.args.solver) - self.run.run() + self.run.run() def post_process(self): """Perform post-run actions, like plotting the mfile.""" @@ -253,13 +253,11 @@ def __init__(self, config_file, solver="vmcon"): # Store the absolute path to the config file immediately: various # dir changes happen in old run_process code self.config_file = Path(config_file).resolve() - self.run(solver) + self.solver = solver - def run(self, solver): + def run(self): """Perform a VaryRun by running multiple SingleRuns. - :param solver: which solver to use, as specified in solver.py - :type solver: str :raises FileNotFoundError: if input file doesn't exist """ # The input path for the varied input file @@ -301,7 +299,7 @@ def run(self, solver): # TODO Don't do this; remove stop statements from Fortran and # handle error codes # Run process on an IN.DAT file - config.run_process(input_path, solver) + config.run_process(input_path, self.solver) check_input_error(wdir=wdir) diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index c910d61ea..d584f4fc4 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -108,6 +108,7 @@ def test_run_mode(process_obj, monkeypatch): # Mock VaryRun() (don't want it to actually run), then assert run type is # VaryRun monkeypatch.setattr(VaryRun, "__init__", mock_init) + monkeypatch.setattr(VaryRun, "run", mock_run) process_obj.run_mode() assert isinstance(process_obj.run, VaryRun)