From ad4a3fb442d7263d84876f66657b66001097330f Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 11 Feb 2022 13:29:24 -0600 Subject: [PATCH 1/6] Allow other plugins to use supp_inputs --- src/watts/plugin.py | 35 +++++++++++++++++++++++++---------- src/watts/plugin_moose.py | 14 +++++++------- src/watts/plugin_openmc.py | 24 +++++++++++++++++------- 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/watts/plugin.py b/src/watts/plugin.py index 100607ba..5c1fb2ee 100644 --- a/src/watts/plugin.py +++ b/src/watts/plugin.py @@ -2,22 +2,32 @@ # SPDX-License-Identifier: MIT from abc import ABC, abstractmethod -import os from pathlib import Path import shutil -from typing import Optional +from typing import Optional, List from astropy import units as u import copy from .database import Database -from .fileutils import cd_tmpdir +from .fileutils import cd_tmpdir, PathLike from .parameters import Parameters from .results import Results from .template import TemplateModelBuilder class Plugin(ABC): - """Class defining the Plugin interface""" + """Class defining the Plugin interface + + Parameters + ---------- + supp_inputs + Supplemental input files + """ + + def __init__(self, supp_inputs: Optional[List[PathLike]] = None): + self.supp_inputs = [] + if supp_inputs is not None: + self.supp_inputs = [Path(f).resolve() for f in supp_inputs] @abstractmethod def prerun(self, params): @@ -61,11 +71,12 @@ def workflow(self, params: Parameters, name='Workflow') -> Results: db = Database() with cd_tmpdir(): + # Copy supplemental inputs to temporary directory + cwd = Path.cwd() + for path in self.supp_inputs: + shutil.copy(str(path), str(cwd)) # Remove str() for Python 3.8+ + # Run workflow in temporary directory - if hasattr(self, 'supp_inputs'): - des = os.getcwd() - for sifp in self.supp_inputs: - shutil.copy(str(sifp), des) self.prerun(params) self.run() result = self.postrun(params) @@ -112,7 +123,7 @@ def convert_unit(self, params: Parameters, unit_system: str, unit_temperature: s if isinstance(params_copy[key], u.quantity.Quantity): - # Unit conversion for temperature needs to be done separately because + # Unit conversion for temperature needs to be done separately because # astropy uses a different method to convert temperature. # Variables are converted to SI by default. @@ -133,8 +144,12 @@ class TemplatePlugin(Plugin): ---------- template_file Path to template file + supp_inputs + Supplemental input files + """ - def __init__(self, template_file: str): + def __init__(self, template_file: str, supp_inputs: Optional[List[PathLike]] = None): + super().__init__(self, supp_inputs) self.model_builder = TemplateModelBuilder(template_file) def prerun(self, params: Parameters, filename: Optional[str] = None): diff --git a/src/watts/plugin_moose.py b/src/watts/plugin_moose.py index 700eb0cb..588093e2 100644 --- a/src/watts/plugin_moose.py +++ b/src/watts/plugin_moose.py @@ -3,12 +3,10 @@ from contextlib import redirect_stdout, redirect_stderr from datetime import datetime -import os from pathlib import Path import shutil -import subprocess import time -from typing import List +from typing import List, Optional import h5py import numpy as np @@ -130,8 +128,9 @@ class PluginMOOSE(TemplatePlugin): """ def __init__(self, template_file: str, show_stdout: bool = False, - show_stderr: bool = False, n_cpu: int = 1, supp_inputs: List[str] = []): - super().__init__(template_file) + show_stderr: bool = False, n_cpu: int = 1, + supp_inputs: Optional[List[str]] = None): + super().__init__(template_file, supp_inputs) self._moose_exec = Path('moose-opt') self.moose_inp_name = "MOOSE.i" self.show_stdout = show_stdout @@ -139,7 +138,6 @@ def __init__(self, template_file: str, show_stdout: bool = False, if n_cpu < 1: raise RuntimeError("The CPU number used to run MOOSE app must be a natural number.") self.n_cpu = n_cpu - self.supp_inputs = [Path(f).resolve() for f in supp_inputs] @property def moose_exec(self) -> Path: @@ -206,6 +204,8 @@ def postrun(self, params: Parameters) -> ResultsMOOSE: print("Post-run for MOOSE Plugin") time = datetime.fromtimestamp(self._run_time * 1e-9) - inputs = ['MOOSE.i'] + # Start with non-templated input files + inputs = [Path.cwd() / p.name for p in self.supp_inputs] + inputs.append('MOOSE.i') outputs = [p for p in Path.cwd().iterdir() if p.name not in inputs] return ResultsMOOSE(params, time, inputs, outputs) \ No newline at end of file diff --git a/src/watts/plugin_openmc.py b/src/watts/plugin_openmc.py index 69ba3c5a..f6e84f57 100644 --- a/src/watts/plugin_openmc.py +++ b/src/watts/plugin_openmc.py @@ -6,7 +6,7 @@ from functools import lru_cache from pathlib import Path import time -from typing import Callable, Mapping, List +from typing import Callable, Mapping, List, Optional import h5py @@ -103,15 +103,19 @@ class PluginOpenMC(Plugin): ---------- model_builder Function that generates an OpenMC model + supp_inputs + Supplemental input files show_stdout - Whether to display output from stdout when SAM is run + Whether to display output from stdout when OpenMC is run show_stderr - Whether to display output from stderr when SAM is run + Whether to display output from stderr when OpenMC is run """ - def __init__(self, model_builder: Callable[[Parameters], None], + def __init__(self, model_builder: Optional[Callable[[Parameters], None]] = None, + supp_inputs: Optional[List[PathLike]] = None, show_stdout: bool = False, show_stderr: bool = False): + super().__init__(supp_inputs) self.model_builder = model_builder self.show_stdout = show_stdout self.show_stderr = show_stderr @@ -131,7 +135,8 @@ def prerun(self, params: Parameters) -> None: print("Pre-run for OpenMC Plugin") self._run_time = time.time_ns() - self.model_builder(params_copy) + if self.model_builder is not None: + self.model_builder(params_copy) def run(self, **kwargs: Mapping): """Run OpenMC @@ -174,8 +179,13 @@ def files_since(pattern, time): matches.sort(key=lambda x: x.stat().st_mtime_ns) return matches + # Start with non-templated input files + inputs = [Path.cwd() / p.name for p in self.supp_inputs] + # Get generated input files - inputs = files_since('*.xml', self._run_time) + for path in files_since('*.xml', self._run_time): + if path not in inputs: + inputs.append(path) # Get list of all output files outputs = ['OpenMC_log.txt'] @@ -185,4 +195,4 @@ def files_since(pattern, time): outputs.extend(files_since('statepoint.*.h5', self._run_time)) time = datetime.fromtimestamp(self._run_time * 1e-9) - return ResultsOpenMC(params, time, inputs, outputs) \ No newline at end of file + return ResultsOpenMC(params, time, inputs, outputs) From 5bf0f9fb194a6304a11b4982cfe41169b640d89d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 11 Feb 2022 13:29:33 -0600 Subject: [PATCH 2/6] Add __repr__ method to Results class --- src/watts/results.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/watts/results.py b/src/watts/results.py index e53ca884..aedcc729 100644 --- a/src/watts/results.py +++ b/src/watts/results.py @@ -107,3 +107,6 @@ def from_hdf5(cls, filename: PathLike): def open_folder(self): """Open folder containing results""" open_file(self.base_path) + + def __repr__(self): + return f"" From 5c2e91b6d9030bb7f09daef0cee17f790400f80e Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 11 Feb 2022 13:32:54 -0600 Subject: [PATCH 3/6] Rename supp_inputs --> extra_inputs --- examples/example5_multiapps/example5a.py | 2 +- examples/example6_adv_multiapps/example6.py | 6 +++--- src/watts/plugin.py | 24 ++++++++++----------- src/watts/plugin_moose.py | 10 ++++----- src/watts/plugin_openmc.py | 10 ++++----- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/example5_multiapps/example5a.py b/examples/example5_multiapps/example5a.py index e07fc285..5fcc7070 100644 --- a/examples/example5_multiapps/example5a.py +++ b/examples/example5_multiapps/example5a.py @@ -18,7 +18,7 @@ moose_app_type = "bison" app_dir = os.environ[moose_app_type.upper() + "_DIR"] -moose_plugin = watts.PluginMOOSE('main.tmpl', supp_inputs=['main_in.e', 'sub.i']) +moose_plugin = watts.PluginMOOSE('main.tmpl', extra_inputs=['main_in.e', 'sub.i']) moose_plugin.moose_exec = app_dir + "/" + moose_app_type.lower() + "-opt" moose_result = moose_plugin.workflow(params) for key in moose_result.csv_data: diff --git a/examples/example6_adv_multiapps/example6.py b/examples/example6_adv_multiapps/example6.py index a7bf9d2d..eeeb3636 100644 --- a/examples/example6_adv_multiapps/example6.py +++ b/examples/example6_adv_multiapps/example6.py @@ -39,7 +39,7 @@ # MOOSE Workflow for steady state print("Steady-state calculation") -moose_plugin_ss = watts.PluginMOOSE('MP_ss_griffin.tmpl', n_cpu=40, supp_inputs=['MP_ss_moose.i', 'MP_ss_sockeye.i', '3D_unit_cell_FY21_level-1_bison.e', '3D_unit_cell_FY21_supersimple.e', 'unitcell_nogap_hom_xml_G11_df_MP.xml']) +moose_plugin_ss = watts.PluginMOOSE('MP_ss_griffin.tmpl', n_cpu=40, extra_inputs=['MP_ss_moose.i', 'MP_ss_sockeye.i', '3D_unit_cell_FY21_level-1_bison.e', '3D_unit_cell_FY21_supersimple.e', 'unitcell_nogap_hom_xml_G11_df_MP.xml']) moose_plugin_ss.moose_exec = app_dir + "/" + moose_app_type.lower() + "-opt" moose_result_ss = moose_plugin_ss.workflow(params_ss) for key in moose_result_ss.csv_data: @@ -55,7 +55,7 @@ # MOOSE Workflow for Null transient print("Null transient calculation") -moose_plugin_trN = watts.PluginMOOSE('MP_trN_griffin.tmpl', n_cpu=40, show_stdout=False, supp_inputs=['MP_trN_moose.i', 'MP_trN_sockeye.i', 'unitcell_nogap_hom_xml_G11_df_MP.xml']) +moose_plugin_trN = watts.PluginMOOSE('MP_trN_griffin.tmpl', n_cpu=40, show_stdout=False, extra_inputs=['MP_trN_moose.i', 'MP_trN_sockeye.i', 'unitcell_nogap_hom_xml_G11_df_MP.xml']) moose_plugin_trN.moose_exec = app_dir + "/" + moose_app_type.lower() + "-opt" moose_result_trN = moose_plugin_trN.workflow(params_trN) for key in moose_result_trN.csv_data: @@ -75,7 +75,7 @@ # MOOSE Workflow for transient print("Transient calculation") -moose_plugin_tr = watts.PluginMOOSE('MP_tr_griffin.tmpl', n_cpu=40, show_stdout=True, supp_inputs=['MP_tr_moose.i', 'MP_tr_sockeye.i', 'unitcell_nogap_hom_xml_G11_df_MP.xml']) +moose_plugin_tr = watts.PluginMOOSE('MP_tr_griffin.tmpl', n_cpu=40, show_stdout=True, extra_inputs=['MP_tr_moose.i', 'MP_tr_sockeye.i', 'unitcell_nogap_hom_xml_G11_df_MP.xml']) moose_plugin_tr.moose_exec = app_dir + "/" + moose_app_type.lower() + "-opt" moose_result_tr = moose_plugin_tr.workflow(params_tr) for key in moose_result_tr.csv_data: diff --git a/src/watts/plugin.py b/src/watts/plugin.py index 5c1fb2ee..87f6d526 100644 --- a/src/watts/plugin.py +++ b/src/watts/plugin.py @@ -20,14 +20,14 @@ class Plugin(ABC): Parameters ---------- - supp_inputs - Supplemental input files + extra_inputs + Extra (non-templated) input files """ - def __init__(self, supp_inputs: Optional[List[PathLike]] = None): - self.supp_inputs = [] - if supp_inputs is not None: - self.supp_inputs = [Path(f).resolve() for f in supp_inputs] + def __init__(self, extra_inputs: Optional[List[PathLike]] = None): + self.extra_inputs = [] + if extra_inputs is not None: + self.extra_inputs = [Path(f).resolve() for f in extra_inputs] @abstractmethod def prerun(self, params): @@ -71,9 +71,9 @@ def workflow(self, params: Parameters, name='Workflow') -> Results: db = Database() with cd_tmpdir(): - # Copy supplemental inputs to temporary directory + # Copy extra inputs to temporary directory cwd = Path.cwd() - for path in self.supp_inputs: + for path in self.extra_inputs: shutil.copy(str(path), str(cwd)) # Remove str() for Python 3.8+ # Run workflow in temporary directory @@ -144,12 +144,12 @@ class TemplatePlugin(Plugin): ---------- template_file Path to template file - supp_inputs - Supplemental input files + extra_inputs + Extra (non-templated) input files """ - def __init__(self, template_file: str, supp_inputs: Optional[List[PathLike]] = None): - super().__init__(self, supp_inputs) + def __init__(self, template_file: str, extra_inputs: Optional[List[PathLike]] = None): + super().__init__(extra_inputs) self.model_builder = TemplateModelBuilder(template_file) def prerun(self, params: Parameters, filename: Optional[str] = None): diff --git a/src/watts/plugin_moose.py b/src/watts/plugin_moose.py index 588093e2..11a4b5d9 100644 --- a/src/watts/plugin_moose.py +++ b/src/watts/plugin_moose.py @@ -117,8 +117,8 @@ class PluginMOOSE(TemplatePlugin): Whether to display output from stderr when MOOSE is run n_cpu Number of processors to be used to run MOOSE application - supp_inputs - List of supplementary input files that are needed for running the MOOSE application + extra_inputs + List of extra (non-templated) input files that are needed Attributes ---------- @@ -129,8 +129,8 @@ class PluginMOOSE(TemplatePlugin): def __init__(self, template_file: str, show_stdout: bool = False, show_stderr: bool = False, n_cpu: int = 1, - supp_inputs: Optional[List[str]] = None): - super().__init__(template_file, supp_inputs) + extra_inputs: Optional[List[str]] = None): + super().__init__(template_file, extra_inputs) self._moose_exec = Path('moose-opt') self.moose_inp_name = "MOOSE.i" self.show_stdout = show_stdout @@ -205,7 +205,7 @@ def postrun(self, params: Parameters) -> ResultsMOOSE: time = datetime.fromtimestamp(self._run_time * 1e-9) # Start with non-templated input files - inputs = [Path.cwd() / p.name for p in self.supp_inputs] + inputs = [Path.cwd() / p.name for p in self.extra_inputs] inputs.append('MOOSE.i') outputs = [p for p in Path.cwd().iterdir() if p.name not in inputs] return ResultsMOOSE(params, time, inputs, outputs) \ No newline at end of file diff --git a/src/watts/plugin_openmc.py b/src/watts/plugin_openmc.py index f6e84f57..a1926703 100644 --- a/src/watts/plugin_openmc.py +++ b/src/watts/plugin_openmc.py @@ -103,8 +103,8 @@ class PluginOpenMC(Plugin): ---------- model_builder Function that generates an OpenMC model - supp_inputs - Supplemental input files + extra_inputs + Extra (non-templated) input files show_stdout Whether to display output from stdout when OpenMC is run show_stderr @@ -113,9 +113,9 @@ class PluginOpenMC(Plugin): """ def __init__(self, model_builder: Optional[Callable[[Parameters], None]] = None, - supp_inputs: Optional[List[PathLike]] = None, + extra_inputs: Optional[List[PathLike]] = None, show_stdout: bool = False, show_stderr: bool = False): - super().__init__(supp_inputs) + super().__init__(extra_inputs) self.model_builder = model_builder self.show_stdout = show_stdout self.show_stderr = show_stderr @@ -180,7 +180,7 @@ def files_since(pattern, time): return matches # Start with non-templated input files - inputs = [Path.cwd() / p.name for p in self.supp_inputs] + inputs = [Path.cwd() / p.name for p in self.extra_inputs] # Get generated input files for path in files_since('*.xml', self._run_time): From 4bec036d15a6d6dc400c20b00d5ab88f599cda06 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 11 Feb 2022 13:59:33 -0600 Subject: [PATCH 4/6] Add OpenMC plugin test with extra_inputs --- tests/test_plugin_openmc.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_plugin_openmc.py b/tests/test_plugin_openmc.py index 8530fa6a..3a33f664 100644 --- a/tests/test_plugin_openmc.py +++ b/tests/test_plugin_openmc.py @@ -69,3 +69,26 @@ def test_openmc_plugin(): assert last_result.outputs == result.outputs assert last_result.keff.n == result.keff.n assert last_result.keff.s == result.keff.s + + +def test_extra_inputs(run_in_tmpdir): + # Create inputs manually -- 10 cm sphere of pure Pu239 + model = openmc.model.Model() + mat = openmc.Material() + mat.add_nuclide('Pu239', 1.0) + mat.set_density('g/cm3', 10.0) + sph = openmc.Sphere(r=10.0, boundary_type='vacuum') + cell = openmc.Cell(fill=mat, region=-sph) + model.geometry = openmc.Geometry([cell]) + model.settings.batches = 10 + model.settings.inactive = 0 + model.settings.particles = 1000 + model.export_to_xml() + + # Use OpenMC plugin with extra inputs + plugin = watts.PluginOpenMC(extra_inputs=['geometry.xml', 'materials.xml', 'settings.xml']) + params = watts.Parameters() + result = plugin.workflow(params) + + input_names = {p.name for p in result.inputs} + assert input_names == {'geometry.xml', 'materials.xml', 'settings.xml'} From 991fc4fed1901021bfde57700ab62925566b1efe Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 11 Feb 2022 14:05:27 -0600 Subject: [PATCH 5/6] Add CI status badge on README.md --- README.md | 2 ++ setup.cfg | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d7fcee17..9dc0ff0d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # WATTS [![License](https://img.shields.io/badge/license-MIT-green)](https://opensource.org/licenses/MIT) +[![GitHub Actions build status (Linux)](https://github.com/watts-dev/watts/workflows/CI/badge.svg?branch=development)](https://github.com/watts-dev/watts/actions?query=workflow%3ACI) + WATTS (Workflow and Template Toolkit for Simulation) provides a set of Python classes that can manage simulation workflows for multiple codes where diff --git a/setup.cfg b/setup.cfg index c6065968..c1b97720 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ name = watts version = 0.0.1 author = UChicago Argonne, LLC -author_email = nstauff@anl.gov +author_email = watts@anl.gov description = Workflow and Template Toolkit for Simulation long_description = file: README.md long_description_content_type = text/markdown From 7b13c2772291d16afd672a4b5df2cd1f1062623c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 17 Feb 2022 16:56:21 -0600 Subject: [PATCH 6/6] Change PluginPyARC to use extra_inputs --- doc/source/user/usage.rst | 32 ++++++++++++++------------- examples/example1c_PyARC/example1c.py | 2 +- src/watts/plugin_moose.py | 4 ++-- src/watts/plugin_pyarc.py | 22 +++++++++--------- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/doc/source/user/usage.rst b/doc/source/user/usage.rst index 79c5d851..438ea584 100644 --- a/doc/source/user/usage.rst +++ b/doc/source/user/usage.rst @@ -56,15 +56,16 @@ added to WATTS and are available for your use. MOOSE Plugin ~~~~~~~~~~ -The :class:`~watts.PluginMOOSE` class enables MOOSE simulations using a templated -input file. This is demonstrated here for a SAM application, but other examples based on BISON are also available. -For MOOSE codes such as SAM or BISON that use text-based input files, WATTS relies on -the `Jinja `_ templating engine for handling -templated variables and expressions. The templated input file looks like a -normal MOOSE input file where some values have been replaced with -**variables**, which are denoted by ``{{`` and ``}}`` pairs and get replaced -with actual values when the template is *rendered*. For example, a templated -input file might look as follows: +The :class:`~watts.PluginMOOSE` class enables MOOSE simulations using a +templated input file. This is demonstrated here for a SAM application, but other +examples based on BISON are also available. For MOOSE codes such as SAM or BISON +that use text-based input files, WATTS relies on the `Jinja +`_ templating engine for handling templated +variables and expressions. The templated input file looks like a normal MOOSE +input file where some values have been replaced with **variables**, which are +denoted by ``{{`` and ``}}`` pairs and get replaced with actual values when the +template is *rendered*. For example, a templated input file might look as +follows: .. code-block:: jinja @@ -81,8 +82,9 @@ If the templated input file is ``sam_template.inp``, the SAM code will rely the moose_plugin = watts.PluginMOOSE('sam_template.inp') -The MOOSE plugin provides the option to specify supplementary input files (in `supp_inputs` option) that -will be copied together with the templated input file (mesh or cross-section files). +The MOOSE plugin provides the option to specify non-templated input files (in +`extra_inputs` option) that will be copied together with the templated input +file (mesh or cross-section files). The SAM executable defaults to ``sam-opt`` (assumed to be present on your :envvar:`PATH`) but can also be specified explicitly with the @@ -163,7 +165,7 @@ PyARC Plugin ~~~~~~~~~~~~~ The :class:`~watts.PluginPyARC` class handles PyARC execution in a similar -manner to the :class:`~watts.PluginSAM` class for SAM. PyARC use text-based +manner to the :class:`~watts.PluginSAM` class for SAM. PyARC use text-based input files which can be templated as follows: .. code-block:: jinja @@ -176,15 +178,15 @@ input files which can be templated as follows: If the templated input file is `pyarc_template`, then the PyARC plugin can be instantiated with following command line:: - pyarc_plugin = watts.PluginPyARC('pyarc_template', show_stdout=True, supp_inputs=['lumped_test5.son']) + pyarc_plugin = watts.PluginPyARC('pyarc_template', show_stdout=True, extra_inputs=['lumped_test5.son']) The path to PyARC directory must be specified explicitly with the :attr:`~watts.PluginPyARC.pyarc_exec` attribute:: pyarc_plugin.pyarc_exec = "/path/to/PyARC" -To execute PyARC, the :meth:`~watts.PluginPyARC.workflow` method is called -the same way as other Plugins. +To execute PyARC, the :meth:`~watts.PluginPyARC.workflow` method is called +the same way as other Plugins. Results +++++++ diff --git a/examples/example1c_PyARC/example1c.py b/examples/example1c_PyARC/example1c.py index abb573b2..d43c0182 100644 --- a/examples/example1c_PyARC/example1c.py +++ b/examples/example1c_PyARC/example1c.py @@ -15,7 +15,7 @@ # PyARC Workflow -pyarc_plugin = watts.PluginPyARC('pyarc_template', show_stdout=True, supp_inputs=['lumped_test5.son']) # show all the output +pyarc_plugin = watts.PluginPyARC('pyarc_template', show_stdout=True, extra_inputs=['lumped_test5.son']) # show all the output pyarc_result = pyarc_plugin.workflow(params) for key in pyarc_result.results_data: print(key, pyarc_result.results_data[key]) diff --git a/src/watts/plugin_moose.py b/src/watts/plugin_moose.py index 11a4b5d9..3c773be7 100644 --- a/src/watts/plugin_moose.py +++ b/src/watts/plugin_moose.py @@ -205,7 +205,7 @@ def postrun(self, params: Parameters) -> ResultsMOOSE: time = datetime.fromtimestamp(self._run_time * 1e-9) # Start with non-templated input files - inputs = [Path.cwd() / p.name for p in self.extra_inputs] + inputs = [p.name for p in self.extra_inputs] inputs.append('MOOSE.i') outputs = [p for p in Path.cwd().iterdir() if p.name not in inputs] - return ResultsMOOSE(params, time, inputs, outputs) \ No newline at end of file + return ResultsMOOSE(params, time, inputs, outputs) diff --git a/src/watts/plugin_pyarc.py b/src/watts/plugin_pyarc.py index 7d6a0e3b..201dc1c3 100644 --- a/src/watts/plugin_pyarc.py +++ b/src/watts/plugin_pyarc.py @@ -6,7 +6,7 @@ import os import tempfile import time -from typing import Mapping, List +from typing import Mapping, List, Optional import h5py import sys @@ -62,7 +62,7 @@ def _save_PyARC(self, user_object) -> dict: results_data["persent_sens"] = user_object.results_kuq_persent results_data["gamsor"] = user_object.results_power_gamsor results_data["dassh"] = user_object.results_dassh - # TODO - this is minimum information that can be brought back easily. + # TODO - this is minimum information that can be brought back easily. # More should be returned but will require work on PyARC. return results_data @@ -98,12 +98,12 @@ class PluginPyARC(TemplatePlugin): template_file Templated PyARC input show_stdout - Whether to display output from stdout when SAM is run + Whether to display output from stdout when PyARC is run show_stderr - Whether to display output from stderr when SAM is run - supp_inputs - List of supplementary input files that are needed for running PyARC - + Whether to display output from stderr when PyARC is run + extra_inputs + List of extra (non-templated) input files that are needed + Attributes ---------- pyarc_exec @@ -112,13 +112,13 @@ class PluginPyARC(TemplatePlugin): """ def __init__(self, template_file: str, show_stdout: bool = False, - show_stderr: bool = False, supp_inputs: List[str] = []): - super().__init__(template_file) + show_stderr: bool = False, + extra_inputs: Optional[List[str]] = None): + super().__init__(template_file, extra_inputs) self._pyarc_exec = Path(os.environ.get('PyARC_DIR', 'PyARC.py')) self.pyarc_inp_name = "pyarc_input.son" self.show_stdout = show_stdout self.show_stderr = show_stderr - self.supp_inputs = [Path(f).resolve() for f in supp_inputs] @property def pyarc_exec(self) -> Path: @@ -178,7 +178,7 @@ def postrun(self, params: Parameters) -> ResultsPyARC: print("Post-run for PyARC Plugin") time = datetime.fromtimestamp(self._run_time * 1e-9) - inputs = [p.name for p in self.supp_inputs] + inputs = [p.name for p in self.extra_inputs] inputs.append(self.pyarc_inp_name) outputs = [p for p in Path.cwd().iterdir() if p.name not in inputs] return ResultsPyARC(params, time, inputs, outputs, self.pyarc.user_object)