Skip to content

Commit 41793df

Browse files
Merge pull request NREL#154 from softwareengineerprogrammer/main
MC CLI enhancement, miscellaneous updates
2 parents 796f013 + a216a1a commit 41793df

File tree

14 files changed

+66
-23
lines changed

14 files changed

+66
-23
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.4.19
2+
current_version = 3.4.20
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.4.19
57+
version: 3.4.20
5858
version_manager: "bump2version"
5959
website: "https://github.com/NREL"
6060
year_from: "2023"

.github/workflows/github-actions.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ jobs:
101101
# os: 'macos-latest'
102102

103103
steps:
104-
- uses: actions/checkout@v3
104+
- uses: actions/checkout@v4
105105
with:
106106
fetch-depth: 0
107-
- uses: actions/setup-python@v4
107+
- uses: actions/setup-python@v5
108108
with:
109109
python-version: ${{ matrix.python }}
110110
architecture: ${{ matrix.python_arch }}
@@ -131,10 +131,10 @@ jobs:
131131
needs: test
132132
runs-on: ubuntu-latest
133133
steps:
134-
- uses: actions/checkout@v3
134+
- uses: actions/checkout@v4
135135
with:
136136
fetch-depth: 0
137-
- uses: actions/setup-python@v4
137+
- uses: actions/setup-python@v5
138138
with:
139139
python-version: '3.11'
140140
architecture: 'x64'
@@ -162,8 +162,8 @@ jobs:
162162
done
163163
164164
- name: upload artifact
165-
uses: actions/upload-pages-artifact@v2
165+
uses: actions/upload-pages-artifact@v3
166166

167167
- name: deploy to GitHub Pages
168168
id: deployment
169-
uses: actions/deploy-pages@v2
169+
uses: actions/deploy-pages@v4

README.rst

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

50-
.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.4.19.svg
50+
.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.4.20.svg
5151
:alt: Commits since latest release
52-
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.4.19...main
52+
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.4.20...main
5353

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

ci/templates/.github/workflows/github-actions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ jobs:
4343
{% endfor %}
4444
{% endfor %}
4545
steps:
46-
- uses: actions/checkout@v3
46+
- uses: actions/checkout@v4
4747
with:
4848
fetch-depth: 0
49-
- uses: actions/setup-python@v4
49+
- uses: actions/setup-python@v5
5050
with:
5151
python-version: {{ '${{ matrix.python }}' }}
5252
architecture: {{ '${{ matrix.python_arch }}' }}

docs/Monte-Carlo-User-Guide.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ bin edges: [-43.34 -43.2258 -43.1116 -42.9974 -42.8832 -42.769 -42.6548 -42.5
109109
110110
```
111111

112+
You may also run from the command line:
113+
114+
```
115+
python -mgeophires_monte_carlo GEOPHIRESv3.py GEOPHIRES-example1.txt MC_GEOPHIRES_Settings_file.txt MC_GEOPHIRES_Result.txt
116+
```
117+
112118
## Documentation
113119

114120
See [module documentation](reference/geophires_monte_carlo.html)

docs/conf.py

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

src/geophires_monte_carlo/MC_GeoPHIRES3.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,6 @@ def main(command_line_args=None):
240240
# keep track of execution time
241241
tic = time.time()
242242

243-
# set the starting directory to be the directory that this file is in
244-
working_dir = os.path.dirname(os.path.abspath(__file__))
245-
os.chdir(working_dir)
246-
working_dir = working_dir + os.sep
247-
248243
# get the values off the command line
249244
parser = argparse.ArgumentParser()
250245
parser.add_argument('Code_File', help='Code File')
@@ -268,7 +263,11 @@ def main(command_line_args=None):
268263
inputs = []
269264
outputs = []
270265
iterations = 0
271-
output_file = args.MC_OUTPUT_FILE if 'MC_OUTPUT_FILE' in args and args.MC_OUTPUT_FILE is not None else ''
266+
output_file = (
267+
args.MC_OUTPUT_FILE
268+
if 'MC_OUTPUT_FILE' in args and args.MC_OUTPUT_FILE is not None
269+
else str(Path(Path(args.Input_file).parent, 'MC_Result.txt').absolute())
270+
)
272271
python_path = 'python'
273272

274273
for line in flist:
@@ -312,6 +311,11 @@ def main(command_line_args=None):
312311
with open(output_file, 'w') as f:
313312
f.write(s)
314313

314+
# set the starting directory to be the directory that this file is in
315+
working_dir = os.path.dirname(os.path.abspath(__file__))
316+
os.chdir(working_dir)
317+
working_dir = working_dir + os.sep
318+
315319
# build the args list
316320
pass_list = [inputs, outputs, args, output_file, working_dir, python_path] # this list never changes
317321

src/geophires_monte_carlo/__main__.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import sys
3+
from pathlib import Path
4+
5+
from geophires_monte_carlo import MC_GeoPHIRES3
6+
from geophires_monte_carlo import common
7+
8+
if __name__ == '__main__':
9+
log = common._get_logger()
10+
stash_cwd = Path.cwd()
11+
12+
try:
13+
command_line_args = []
14+
for i in range(len(sys.argv[1:])):
15+
arg = sys.argv[i + 1]
16+
if Path(arg).exists():
17+
arg = str(Path(arg).absolute())
18+
log.info(f'Converted arg to absolute path: {arg}')
19+
20+
command_line_args.append(arg)
21+
22+
MC_GeoPHIRES3.main(command_line_args=command_line_args)
23+
except Exception as e:
24+
raise RuntimeError(f'Monte Carlo encountered an exception: {e!s}') from e
25+
except SystemExit:
26+
raise RuntimeError('Monte Carlo exited without giving a reason') from None
27+
finally:
28+
# Undo MC internal global settings changes
29+
os.chdir(stash_cwd)

0 commit comments

Comments
 (0)