Skip to content

Commit

Permalink
WIP injection of model into run, unify SingleRun and VaryRun run
Browse files Browse the repository at this point in the history
  • Loading branch information
je-cook authored and timothy-nunn committed Feb 8, 2024
1 parent decf764 commit c7c73fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions process/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c7c73fa

Please sign in to comment.