Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding demo files to build_and_test.sh run #55

Merged
merged 24 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3ea2802
[DRAFT] adding demo files to build_and_test.sh run
robinsteuteville Oct 4, 2023
178448c
making run_all.py, running all .py files with demo in title, adding t…
robinsteuteville Oct 12, 2023
c9de773
first attempt at getting the demos files to download with proper vers…
robinsteuteville Oct 12, 2023
87eaa62
updating comments
robinsteuteville Oct 12, 2023
7ab893a
adding demos testing to sh file like in altrios
robinsteuteville Oct 31, 2023
5ba2efb
adding requests to pyproject.toml
robinsteuteville Oct 31, 2023
8110144
tests are now (hopefully) triggered on push to `fastsim-2` or `fastsi…
calbaker Oct 31, 2023
145328a
adding demo tests to git tests and attempt at copy files function
robinsteuteville Nov 1, 2023
5a3e0cd
adding comments
robinsteuteville Nov 1, 2023
d911bb4
updated attempt at adding demos tests to git
robinsteuteville Nov 1, 2023
70d34a0
third attempt at adding demos test to git
robinsteuteville Nov 1, 2023
127f6aa
updating demo copy function
Nov 5, 2023
6846c89
adding working copy_demo_files function to utilities
Nov 8, 2023
9bbbdf8
adding test for copy_demo_files function, deleting unneeded test demo…
Nov 9, 2023
fcc1ecb
attempting to fix conflict with main
Nov 9, 2023
ab74072
troubleshooting fusion thermal demo
Nov 28, 2023
d5f3ba2
continuing troubleshooting fusion_thermal_demo
Nov 29, 2023
139c5f9
fixed fusion_thermal_demo.py file
Nov 29, 2023
4bef2ae
addressing merge conflicts between branch and fastsim-2
Nov 30, 2023
1bf29fc
Update .github/workflows/tests.yaml
robinsteuteville Nov 30, 2023
615ebf3
Update python/fastsim/__init__.py
robinsteuteville Nov 30, 2023
7752854
Update python/fastsim/__init__.py
robinsteuteville Nov 30, 2023
f79cc4f
fixing merge conflict with fastsim-2
Dec 4, 2023
92b3f2f
Merge branch 'fastsim-2' of https://github.com/NREL/fastsim into fix-…
Dec 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
(cd rust/fastsim-core/ && cargo test) && \
(cd rust/fastsim-cli/ && cargo test) && \
pip install -qe ".[dev]" && \
pytest -v python/fastsim/tests/
pytest -v python/fastsim/tests/
(cd python/fastsim/demos/ && python run_all.py)
33 changes: 33 additions & 0 deletions python/fastsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,39 @@ def package_root() -> Path:

__version__ = get_distribution("fastsim").version

#download demo files
robinsteuteville marked this conversation as resolved.
Show resolved Hide resolved
import fastsim
import os
import pathlib
import fnmatch
import requests

p = 'https://github.com/NREL/fastsim/tree/' + fastsim.__version__ + '/python/fastsim/demos'
d = pathlib.Path(__file__).parent
has_demos = False
demos_dir = ''
for dir in os.walk(d):
if fnmatch.fnmatch(dir[0], '*demos'):
has_demos = True
demos_dir = dir[0]
break
if has_demos:
#the problem is I can't figure out how to list the contents of the online demos file
for f in p.get_dir_contents():
already_downloaded = False
for file in demos_dir.glob('*demo*.py'):
#need a way to get the "basename" for the online demos files as well for this to work
if f == os.path.basename(file.replace('\\', '/')): #necessary to ensure command works on all operating systems
already_downloaded = True
print('{} = {} already downloaded'.format(file, f)) #placeholder until I figure out how to download the file
break
if already_downloaded == False:
#download file
print('{} != {} needs downloading'.format(file, f)) #placeholder under I figure out how to download the folder
else:
#just download demos folder
print('demos folder needs downloading')

__doc__ += "\nhttps://pypi.org/project/fastsim/"
__doc__ += "\nhttps://www.nrel.gov/transportation/fastsim.html"

Expand Down
8 changes: 8 additions & 0 deletions python/fastsim/demos/run_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pathlib

p = pathlib.Path(__file__).parent

for file in p.glob('*demo*.py'):
with open(file) as f:
exec(f.read())
print('{} ran successfully'.format(f))