Skip to content

Commit 58fb62a

Browse files
Merge pull request #101 from softwareengineerprogrammer/hip-ra-x-print-output-to-console
HIP-RA-X Print Output to Console [v3.9.50]
2 parents 7a40458 + b9823e6 commit 58fb62a

File tree

9 files changed

+54
-9
lines changed

9 files changed

+54
-9
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.9.49
2+
current_version = 3.9.50
33
commit = True
44
tag = True
55

.cookiecutterrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ default_context:
5454
sphinx_doctest: "no"
5555
sphinx_theme: "sphinx-py3doc-enhanced-theme"
5656
test_matrix_separate_coverage: "no"
57-
version: 3.9.49
57+
version: 3.9.50
5858
version_manager: "bump2version"
5959
website: "https://github.com/NREL"
6060
year_from: "2023"

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ Free software: `MIT license <LICENSE>`__
5858
:alt: Supported implementations
5959
:target: https://pypi.org/project/geophires-x
6060

61-
.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.9.49.svg
61+
.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.9.50.svg
6262
:alt: Commits since latest release
63-
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.9.49...main
63+
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.9.50...main
6464

6565
.. |docs| image:: https://readthedocs.org/projects/GEOPHIRES-X/badge/?style=flat
6666
:target: https://nrel.github.io/GEOPHIRES-X
@@ -288,7 +288,7 @@ Example-specific web interface deeplinks are listed in the Link column.
288288
- `Fervo_Project_Cape-3.txt <tests/examples/Fervo_Project_Cape-3.txt>`__
289289
- `.out <tests/examples/Fervo_Project_Cape-3.out>`__
290290
- `link <https://gtp.scientificwebservices.com/geophires?geophires-example-id=Fervo_Project_Cape-3>`__
291-
* - Case Study: 500 MWe EGS Project Modeled on Fervo Cape Station (`documentation <https://softwareengineerprogrammer.github.io/GEOPHIRES/Fervo_Project_Cape-4.html>`__)
291+
* - Case Study: 500 MWe EGS Project Modeled on Fervo Cape Station (`documentation <https://nrel.github.io/GEOPHIRES-X/Fervo_Project_Cape-4.html>`__)
292292
- `Fervo_Project_Cape-4.txt <tests/examples/Fervo_Project_Cape-4.txt>`__
293293
- `.out <tests/examples/Fervo_Project_Cape-4.out>`__
294294
- `link <https://gtp.scientificwebservices.com/geophires?geophires-example-id=Fervo_Project_Cape-4>`__

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
year = '2025'
1919
author = 'NREL'
2020
copyright = f'{year}, {author}'
21-
version = release = '3.9.49'
21+
version = release = '3.9.50'
2222

2323
pygments_style = 'trac'
2424
templates_path = ['./templates']

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def read(*names, **kwargs):
1313

1414
setup(
1515
name='geophires-x',
16-
version='3.9.49',
16+
version='3.9.50',
1717
license='MIT',
1818
description='GEOPHIRES is a free and open-source geothermal techno-economic simulator.',
1919
long_description='{}\n{}'.format(

src/geophires_x/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.9.49'
1+
__version__ = '3.9.50'

src/geophires_x_schema_generator/hip-ra-x-request.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@
168168
"default": "HIP.html",
169169
"minimum": null,
170170
"maximum": null
171+
},
172+
"Print Output to Console": {
173+
"description": "Provide False if you do not want to print output to the console",
174+
"type": "boolean",
175+
"units": null,
176+
"category": null,
177+
"default": true,
178+
"minimum": null,
179+
"maximum": null
171180
}
172181
}
173182
}

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='Provide False if you do not want 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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import io
12
import logging
23
import os
34
import re
45
import sys
56
import tempfile
67
import unittest
78
import uuid
9+
from contextlib import redirect_stdout
810
from pathlib import Path
911

1012
from geophires_x.Parameter import OutputParameter
@@ -53,6 +55,30 @@ def get_output_file_for_example(example_file: Path):
5355
# TODO
5456
# self.assertFileContentsEqual(expected_result_output_file_path, result.output_file_path)
5557

58+
def test_print_output_to_console(self):
59+
def get_stdout_from_running(print_output_to_console: bool | int) -> str:
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': print_output_to_console,
68+
}
69+
70+
f = io.StringIO()
71+
with redirect_stdout(f):
72+
result: HipRaResult = HipRaXClient().get_hip_ra_result(HipRaInputParameters(params))
73+
74+
self.assertIsNotNone(result)
75+
return f.getvalue()
76+
77+
self.assertIn('***HIP CASE REPORT***', get_stdout_from_running(True))
78+
self.assertNotIn('***HIP CASE REPORT***', get_stdout_from_running(False))
79+
self.assertIn('***HIP CASE REPORT***', get_stdout_from_running(1))
80+
self.assertNotIn('***HIP CASE REPORT***', get_stdout_from_running(0))
81+
5682
def test_result_parsing_1(self):
5783
result = HipRaResult(self._get_test_file_path('hip-result_example-1.out'))
5884
self.assertIsNotNone(result.result)

0 commit comments

Comments
 (0)