-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add profile plotter and pyswmm integration #165
Merged
+1,305
−203
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c199624
updated requirements.txt - added geopandas
bemcdonnell 725330b
First steps to Migrate to PySWMM as dependency
bemcdonnell c05fbfd
Added Network Tracer function and tests
bemcdonnell d9127c3
Merge branch 'master' of https://github.com/aerispaha/swmmio
bemcdonnell 0076c19
fix merge
bemcdonnell 58f5e3c
removed line
bemcdonnell 5024faf
Adding profile plotting code
bemcdonnell 13529da
added function docstrings
bemcdonnell e5961c1
added import error
bemcdonnell 78e5a68
Adding unit test for profiler config info
bemcdonnell 1a705cd
updated requiredments
bemcdonnell 7d17665
add unit tests for and refactor run_models.run
aerispaha f332b05
add report to inp, use in run.py
aerispaha b111808
add simple test of swmmio cli
aerispaha 3f73c42
use jerzy example model for cli test
aerispaha 350aae9
remove unnecessary files from run_models module
aerispaha e8d9849
step commit before pulling changes
bemcdonnell 148fc89
Merge branch 'profile_plotter' of https://github.com/aerispaha/swmmio…
bemcdonnell 3c2c768
fix
bemcdonnell ce5215f
syntax tweaks in utils.functions
aerispaha 1748d2c
add temp unit test duplicate using temp directory
aerispaha c739da8
syntax tweaks in test_functions
aerispaha 0d0735d
rm Example1_parallel_loop.out and Example1_parallel_loop.rpt
aerispaha 83a598d
refactor test_profile such that it doesn't leave .out and .rpt artifacts
aerispaha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ m2r | |
mistune==0.8.4 | ||
# Run dependencies | ||
pyproj>=3.0.0 | ||
geopandas | ||
matplotlib | ||
pyswmm>=1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,61 @@ | ||
import argparse | ||
import os | ||
from itertools import chain | ||
|
||
from swmmio.run_models.run import run_simple, run_hot_start_sequence | ||
from swmmio.run_models import start_pool | ||
|
||
from swmmio import Model | ||
from itertools import chain | ||
import os | ||
import argparse | ||
from multiprocessing import Pool, cpu_count | ||
from datetime import datetime | ||
|
||
#parse the arguments | ||
parser = argparse.ArgumentParser(description='Process some stuff') | ||
parser.add_argument('-r', '--run', dest='model_to_run', nargs="+") | ||
parser.add_argument('-rhs', '--run_hotstart', dest='hotstart_model_to_run', nargs="+") | ||
parser.add_argument('-sp', '--start_pool', dest='start_pool', nargs="+") | ||
parser.add_argument('-cores_left', '--cores_left', dest='cores_left', default=4, type=int) | ||
parser.add_argument('-pp', '--post_process', dest='post_process', nargs="+") | ||
def main(): | ||
# parse the arguments | ||
parser = argparse.ArgumentParser(description='Process some stuff') | ||
parser.add_argument('-r', '--run', dest='model_to_run', nargs="+") | ||
parser.add_argument('-rhs', '--run_hotstart', dest='hotstart_model_to_run', nargs="+") | ||
parser.add_argument('-sp', '--start_pool', dest='start_pool', nargs="+") | ||
parser.add_argument('-cores_left', '--cores_left', dest='cores_left', default=4, type=int) | ||
parser.add_argument('-pp', '--post_process', dest='post_process', nargs="+") | ||
|
||
args = parser.parse_args() | ||
wd = os.getcwd() # current directory script is being called from | ||
|
||
args = parser.parse_args() | ||
wd = os.getcwd() #current directory script is being called from | ||
if args.model_to_run is not None: | ||
|
||
if args.model_to_run is not None: | ||
models_paths = [os.path.join(wd, f) for f in args.model_to_run] | ||
print('Adding models to queue:\n\t{}'.format('\n\t'.join(models_paths))) | ||
|
||
models_paths = [os.path.join(wd, f) for f in args.model_to_run] | ||
print('Adding models to queue:\n\t{}'.format('\n\t'.join(models_paths))) | ||
# run the models in series (one after the other) | ||
list(map(run_simple, models_paths)) | ||
# run_simple(args.model_to_run) | ||
|
||
#run the models in series (one after the other) | ||
list(map(run_simple, models_paths)) | ||
# run_simple(args.model_to_run) | ||
elif args.hotstart_model_to_run is not None: | ||
models_paths = [os.path.join(wd, f) for f in args.hotstart_model_to_run] | ||
print('hotstart_model_to_run the model: {}'.format(args.hotstart_model_to_run)) | ||
# m = Model(args.hotstart_model_to_run) | ||
# run_hot_start_sequence(m)#args.hotstart_model_to_run) | ||
list(map(run_hot_start_sequence, models_paths)) | ||
|
||
elif args.hotstart_model_to_run is not None: | ||
models_paths = [os.path.join(wd, f) for f in args.hotstart_model_to_run] | ||
print('hotstart_model_to_run the model: {}'.format(args.hotstart_model_to_run)) | ||
# m = Model(args.hotstart_model_to_run) | ||
# run_hot_start_sequence(m)#args.hotstart_model_to_run) | ||
list(map(run_hot_start_sequence, models_paths)) | ||
elif args.start_pool is not None: | ||
|
||
elif args.start_pool is not None: | ||
models_dirs = [os.path.join(wd, f) for f in args.start_pool] | ||
print('Searching for models in:\n\t{}'.format('\n\t'.join(models_dirs))) | ||
# combine the segments and options (combinations) into one iterable | ||
inp_paths = [] | ||
for root, dirs, files in chain.from_iterable(os.walk(path) for path in models_dirs): | ||
for f in files: | ||
if f.endswith('.inp') and 'bk' not in root: | ||
# we've found a directory containing an inp | ||
inp_paths.append(os.path.join(root, f)) | ||
|
||
models_dirs = [os.path.join(wd, f) for f in args.start_pool] | ||
print('Searching for models in:\n\t{}'.format('\n\t'.join(models_dirs))) | ||
#combine the segments and options (combinations) into one iterable | ||
inp_paths = [] | ||
for root, dirs, files in chain.from_iterable(os.walk(path) for path in models_dirs): | ||
for f in files: | ||
if f.endswith('.inp') and 'bk' not in root: | ||
#we've found a directory containing an inp | ||
inp_paths.append(os.path.join(root, f)) | ||
# call the main() function in start_pool.py | ||
start_pool.main(inp_paths, args.cores_left) | ||
|
||
print("swmmio has completed running {} models".format(len(inp_paths))) | ||
|
||
#call the main() function in start_pool.py | ||
start_pool.main(inp_paths, args.cores_left) | ||
else: | ||
print('you need to pass in some args') | ||
|
||
print("swmmio has completed running {} models".format(len(inp_paths))) | ||
return 0 | ||
|
||
|
||
else: | ||
print('you need to pass in some args') | ||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aerispaha can you give me some advice here? This could break someone's run if they had python pointing to py2.7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, well we officially dropped support for Python 2.x back in version 0.3.7. Do you think we need to support 2.x to have pyswmm integrated as the model run engine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aerispaha nope! If the user is not running inside an environment, this line just calls “python” rather than the version of python you are using to execute.