Skip to content

Commit 1c08315

Browse files
Support Print Output to Console in HIP-RA-X. WIP to capture/assert logs in unit test
1 parent d8959ab commit 1c08315

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/hip_ra_x/hip_ra_x.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from geophires_x.Parameter import Parameter
2828
from geophires_x.Parameter import ParameterEntry
2929
from geophires_x.Parameter import ReadParameter
30+
from geophires_x.Parameter import boolParameter
3031
from geophires_x.Parameter import floatParameter
3132
from geophires_x.Parameter import intParameter
3233
from geophires_x.Parameter import strParameter
@@ -353,6 +354,15 @@ def parameter_dict_entry(param: Parameter) -> Parameter:
353354
)
354355
)
355356

357+
self.print_output_to_console = parameter_dict_entry(
358+
boolParameter(
359+
'Print Output to Console',
360+
DefaultValue=True,
361+
UnitType=Units.NONE,
362+
ToolTipText='Whether to print output to the console ',
363+
)
364+
)
365+
356366
# Output parameters
357367
self.reservoir_volume = self.OutputParameterDict[self.reservoir_volume.Name] = OutputParameter(
358368
Name='Reservoir Volume (reservoir)',
@@ -925,7 +935,7 @@ def render_scientific(p: Parameter) -> str:
925935
if self.html_output_file.Provided:
926936
# write the outputs to the output file as HTML and the screen as a table
927937
self.PrintOutputsHTML(case_data_inputs, case_data_results, self.html_output_file.value)
928-
else:
938+
elif self.print_output_to_console.value:
929939
# copy the output file to the screen
930940
with open(outputfile, encoding='UTF-8') as f:
931941
content = f.readlines() # store all output in one long list

tests/hip_ra_x_tests/test_hip_ra_x.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ def get_output_file_for_example(example_file: Path):
5353
# TODO
5454
# self.assertFileContentsEqual(expected_result_output_file_path, result.output_file_path)
5555

56+
def test_print_output_to_console(self):
57+
example_files = self._list_test_files_dir(test_files_dir='./examples')
58+
assert len(example_files) > 0 # test integrity check - no files means something is misconfigured
59+
60+
params = {
61+
'Reservoir Temperature': 250.0,
62+
'Rejection Temperature': 60.0,
63+
'Reservoir Porosity': 10.0,
64+
'Reservoir Area': 55.0,
65+
'Reservoir Thickness': 0.25,
66+
'Reservoir Life Cycle': 25,
67+
'Print Output to Console': False,
68+
}
69+
70+
result: HipRaResult = HipRaXClient().get_hip_ra_result(HipRaInputParameters(params))
71+
self.assertIsNotNone(result)
72+
73+
# FIXME WIP verify output not printed to console
74+
5675
def test_result_parsing_1(self):
5776
result = HipRaResult(self._get_test_file_path('hip-result_example-1.out'))
5877
self.assertIsNotNone(result.result)

0 commit comments

Comments
 (0)