Skip to content

Commit 450e84d

Browse files
Merge pull request #38 from softwareengineerprogrammer/disable-forex-api
Disable Forex API
2 parents 0338348 + 50d10f6 commit 450e84d

File tree

7 files changed

+22
-11
lines changed

7 files changed

+22
-11
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.6.1
2+
current_version = 3.6.2
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.6.1
57+
version: 3.6.2
5858
version_manager: "bump2version"
5959
website: "https://github.com/NREL"
6060
year_from: "2023"

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ Free software: `MIT license <LICENSE>`__
5151
:alt: Supported implementations
5252
:target: https://pypi.org/project/geophires-x
5353

54-
.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.6.1.svg
54+
.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.6.2.svg
5555
:alt: Commits since latest release
56-
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.6.1...main
56+
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.6.2...main
5757

5858
.. |docs| image:: https://readthedocs.org/projects/GEOPHIRES-X/badge/?style=flat
5959
:target: https://nrel.github.io/GEOPHIRES-X

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
year = '2024'
1919
author = 'NREL'
2020
copyright = f'{year}, {author}'
21-
version = release = '3.6.1'
21+
version = release = '3.6.2'
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.6.1',
16+
version='3.6.2',
1717
license='MIT',
1818
description='GEOPHIRES is a free and open-source geothermal techno-economic simulator.',
1919
long_description='{}\n{}'.format(

src/geophires_x/Parameter.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from geophires_x.Units import *
2020

2121
_ureg = get_unit_registry()
22+
_DISABLE_FOREX_API = True # See https://github.com/NREL/GEOPHIRES-X/issues/236#issuecomment-2414681434
2223

2324
class HasQuantity(ABC):
2425

@@ -500,15 +501,19 @@ def ConvertUnits(ParamToModify, strUnit: str, model) -> str:
500501

501502
try:
502503
# if we come here, we have a currency conversion to do (USD->EUR, etc.).
504+
505+
if _DISABLE_FOREX_API:
506+
raise RuntimeError('Forex API disabled')
507+
503508
cr = CurrencyRates()
504509
conv_rate = cr.get_rate(currShort, prefShort)
505510
except BaseException as ex:
506511
print(str(ex))
507512
msg = (
508-
f'Error: GEOPHIRES failed to convert your currency for {ParamToModify.Name} to something it '
509-
f'understands. You gave {strUnit} - Are these currency units defined for forex-python? or perhaps the '
510-
f'currency server is down? Please change your units to {ParamToModify.PreferredUnits.value} to '
511-
f'continue. Cannot continue unless you do. Exiting.'
513+
f'Error: GEOPHIRES failed to convert your currency for {ParamToModify.Name} to something it understands. '
514+
f'You gave {strUnit} - conversion may be affected by https://github.com/NREL/GEOPHIRES-X/issues/236. '
515+
f'Please change your units to {ParamToModify.PreferredUnits.value} '
516+
f'to continue. Cannot continue unless you do. Exiting.'
512517
)
513518
print(msg)
514519
model.logger.critical(str(ex))
@@ -710,6 +715,9 @@ def _parameter_with_currency_units_converted_back_to_preferred_units(param: Para
710715
# start the currency conversion process
711716
cc = CurrencyCodes()
712717
try:
718+
if _DISABLE_FOREX_API:
719+
raise RuntimeError('Forex API disabled')
720+
713721
cr = CurrencyRates()
714722
conv_rate = cr.get_rate(currType, prefType)
715723
except BaseException as ex:
@@ -966,6 +974,9 @@ def ConvertOutputUnits(oparam: OutputParameter, newUnit: Units, model):
966974

967975
raise RuntimeError(msg)
968976
try:
977+
if _DISABLE_FOREX_API:
978+
raise RuntimeError('Forex API disabled')
979+
969980
cr = CurrencyRates()
970981
conv_rate = cr.get_rate(prefShort, currShort)
971982
except BaseException as ex:

src/geophires_x/__init__.py

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

0 commit comments

Comments
 (0)