Skip to content

Commit a728710

Browse files
authored
Merge pull request #88 from paulromano/jinja-environment
Store Jinja environment in TemplateRenderer
2 parents 80727ca + 37f1047 commit a728710

File tree

11 files changed

+35
-27
lines changed

11 files changed

+35
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
* ACCERT plugin via the `PluginACCERT` class ([#83](https://github.com/watts-dev/watts/pull/83))
1313
* Command-line tool for inspecting database ([#86](https://github.com/watts-dev/watts/pull/87))
14+
* The `PluginMCNP` class now has an `input_file` property ([#88](https://github.com/watts-dev/watts/pull/88))
1415

1516
### Changes
1617

src/watts/plugin_abce.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ def __init__(
5151
execute_command = [sys.executable, '{self.executable}', '--settings_file', '{self.input_name}']
5252
super().__init__(
5353
executable, execute_command, template_file, extra_inputs,
54-
extra_template_inputs, show_stdout, show_stderr)
54+
extra_template_inputs, 'ABCE', show_stdout, show_stderr)
5555
self.input_name = 'settings.yml'
56-
self.plugin_name = 'ABCE'
5756

5857

5958
class ResultsABCE(Results):

src/watts/plugin_accert.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ def __init__(self, template_file: str,
4545
executable = _find_executable(executable, 'ACCERT_DIR')
4646
execute_command = [sys.executable, '{self.executable}', '-i', '{self.input_name}']
4747
super().__init__(executable, execute_command, template_file, extra_inputs,
48-
extra_template_inputs, show_stdout, show_stderr)
48+
extra_template_inputs, "ACCERT", show_stdout, show_stderr)
4949
self.input_name = "ACCERT_input.son"
50-
self.plugin_name = "ACCERT"
5150

5251
@PluginGeneric.executable.setter
5352
def executable(self, exe: PathLike):

src/watts/plugin_dakota.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _get_Dakota_output(self, params: Parameters) -> dict:
6161
if Path(dakota_out_file_name).exists():
6262
with open(dakota_out_file_name) as f:
6363
col_names = f.readline().split()
64-
df = pd.read_csv(dakota_out_file_name, sep="\s+", skiprows=1, names=col_names)
64+
df = pd.read_csv(dakota_out_file_name, sep=r"\s+", skiprows=1, names=col_names)
6565

6666
for name in col_names:
6767
output_data[name] = np.array(df[name])
@@ -118,10 +118,9 @@ def __init__(
118118
execute_command = ['{self.executable}', '-i', '{self.input_name}']
119119
super().__init__(
120120
executable, execute_command, template_file, extra_inputs,
121-
extra_template_inputs, show_stdout, show_stderr)
121+
extra_template_inputs, "Dakota", show_stdout, show_stderr)
122122

123123
self.input_name = template_file
124-
self.plugin_name = "Dakota"
125124
self._auto_link_files = auto_link_files
126125

127126
# Setup to automatically include all 'extra_inputs' and 'extra_template_inputs'

src/watts/plugin_mcnp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@ class ResultsMCNP(Results):
2626
2727
Attributes
2828
----------
29+
input_file
30+
Rendered MCNP input file
2931
keff
3032
K-effective value
3133
stdout
3234
Standard output from MCNP run
3335
"""
3436

37+
@property
38+
def input_file(self) -> str:
39+
return self.inputs[0].read_text()
40+
3541
@property
3642
def keff(self) -> ufloat:
3743
with open(self.base_path / 'outp', 'r') as f:
@@ -85,7 +91,6 @@ def __init__(
8591
executable = _find_executable(executable, 'MCNP_DIR')
8692
super().__init__(
8793
executable, ['{self.executable}', 'i={self.input_name}'],
88-
template_file, extra_inputs, extra_template_inputs,
94+
template_file, extra_inputs, extra_template_inputs, "MCNP",
8995
show_stdout, show_stderr, unit_system='cgs')
9096
self.input_name = "mcnp_input"
91-
self.plugin_name = "MCNP"

src/watts/plugin_moose.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,5 @@ def __init__(
113113
execute_command = ['{self.executable}', '-i', '{self.input_name}']
114114
super().__init__(
115115
executable, execute_command, template_file, extra_inputs,
116-
extra_template_inputs, show_stdout, show_stderr)
116+
extra_template_inputs, "MOOSE", show_stdout, show_stderr)
117117
self.input_name = "MOOSE.i"
118-
self.plugin_name = "MOOSE"

src/watts/plugin_pyarc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ def __init__(
7373
):
7474
executable = _find_executable(executable, 'PyARC_DIR')
7575
super().__init__(executable, None, template_file, extra_inputs,
76-
extra_template_inputs, show_stdout, show_stderr)
76+
extra_template_inputs, "PyARC", show_stdout, show_stderr)
7777
self.input_name = "pyarc_input.son"
78-
self.plugin_name = "PyARC"
7978

8079
@PluginGeneric.executable.setter
8180
def executable(self, exe: PathLike):

src/watts/plugin_relap5.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ def __init__(
9292
execute_command = ['{self.executable}', '-i', '{self.input_name}']
9393
super().__init__(
9494
executable, execute_command, template_file, extra_inputs,
95-
extra_template_inputs, show_stdout, show_stderr)
95+
extra_template_inputs, "RELAP5", show_stdout, show_stderr)
9696
self.input_name = "RELAP5.i"
97-
self.plugin_name = "RELAP5"
9897
self.plotfl_to_csv = plotfl_to_csv
9998

10099
def run(self, extra_args: Optional[List[str]] = None):

src/watts/plugin_sas.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ def __init__(
106106
execute_command = ['{self.executable}', '-i', '{self.input_name}',
107107
'-o', 'out.txt']
108108
super().__init__(executable, execute_command, template_file, extra_inputs,
109-
extra_template_inputs, show_stdout, show_stderr)
109+
extra_template_inputs, "SAS", show_stdout, show_stderr)
110110
self.input_name = "SAS.inp"
111-
self.plugin_name = "SAS"
112111

113112
# Set other executables based on the main SAS executable
114113
suffix = executable.suffix

src/watts/plugin_serpent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def __init__(
6868
executable = _find_executable(executable, 'SERPENT_DIR')
6969
super().__init__(
7070
executable, ['{self.executable}', '{self.input_name}'],
71-
template_file, extra_inputs, extra_template_inputs,
71+
template_file, extra_inputs, extra_template_inputs, "Serpent",
7272
show_stdout, show_stderr, unit_system='cgs'
7373
)
7474
self.input_name = "serpent_input"
75-
self.plugin_name = "Serpent"

0 commit comments

Comments
 (0)