Closed finsberg closed 4 years ago
So with these changes, there are now three ways to run the scripts
python -m gotran gotran2py demo/gotran2py/tentusscher_panfilov_2006_M_cell.ode
gotran gotran2py demo/gotran2py/tentusscher_panfilov_2006_M_cell.ode
gotran2py.py demo/gotran2py/tentusscher_panfilov_2006_M_cell.ode
But it is no longer possible to run it the old way
gotran2py demo/gotran2py/tentusscher_panfilov_2006_M_cell.ode
I'm not sure if this was intended? If so, we should update all demos and docs before merging.
So with these changes, there are now three ways to run the scripts
python -m gotran gotran2py demo/gotran2py/tentusscher_panfilov_2006_M_cell.ode
gotran gotran2py demo/gotran2py/tentusscher_panfilov_2006_M_cell.ode
gotran2py.py demo/gotran2py/tentusscher_panfilov_2006_M_cell.ode
But it is no longer possible to run it the old way
gotran2py demo/gotran2py/tentusscher_panfilov_2006_M_cell.ode
I'm not sure if this was intended? If so, we should update all demos and docs before merging.
I totally agree that this is not what we want. Preferable, it should be possible to run the scripts in the same way as before in addition to using python -m gotran gotran2py
. I have pushed a solution for this (8bde55af9b0ef69c4323ebe3d7ad7629252235e2) where the scripts are added as entry points in stead of scripts.
It seems like the commands take slightly longer to run now, presumably because of extra overhead. The relative change is fairly small though, as the gotran scripts were already quite sluggish, so I don't think it's a big concern.
(gotran) [kghustad@mithrandir 21:28:24 gotran (master)*]$ time gotran2c
Traceback (most recent call last):
File "/Users/kghustad/miniconda3/envs/gotran/bin/gotran2c", line 64, in <module>
raise RuntimeError("Expected a single gotran file argument")
RuntimeError: Expected a single gotran file argument
real 0m0.628s
user 0m0.499s
sys 0m0.123s
(gotran) [kghustad@mithrandir 21:28:27 gotran (master)*]$ time gotran2c
Traceback (most recent call last):
File "/Users/kghustad/miniconda3/envs/gotran/bin/gotran2c", line 64, in <module>
raise RuntimeError("Expected a single gotran file argument")
RuntimeError: Expected a single gotran file argument
real 0m0.628s
user 0m0.499s
sys 0m0.127s
(gotran) [kghustad@mithrandir 21:28:59 gotran (finsberg/run_scripts_as_module)*]$ time gotran2c
Traceback (most recent call last):
File "/Users/kghustad/miniconda3/envs/gotran/bin/gotran2c", line 10, in <module>
sys.exit(main())
File "/Users/kghustad/miniconda3/envs/gotran/lib/python3.7/site-packages/gotran/scripts/gotran2c.py", line 82, in main
raise RuntimeError("Expected a single gotran file argument")
RuntimeError: Expected a single gotran file argument
real 0m0.791s
user 0m0.646s
sys 0m0.139s
(gotran) [kghustad@mithrandir 21:29:00 gotran (finsberg/run_scripts_as_module)*]$ time gotran2c
Traceback (most recent call last):
File "/Users/kghustad/miniconda3/envs/gotran/bin/gotran2c", line 10, in <module>
sys.exit(main())
File "/Users/kghustad/miniconda3/envs/gotran/lib/python3.7/site-packages/gotran/scripts/gotran2c.py", line 82, in main
raise RuntimeError("Expected a single gotran file argument")
RuntimeError: Expected a single gotran file argument
real 0m0.793s
user 0m0.646s
sys 0m0.143s
It is now possible to run gotran scripts, such as
gotran2py
as a module. More specifically, instead of typingin the command line, you can now also do
This makes it more clear which python version that is associated with the executable you want to run.
The way this is implemented is by adding a
__main__.py
(which is what is being executed when you runpython -m gotran
) where all the scripts are imported from a sub package calledscripts
. This makes it also easier to test later (you don't have to spawn subprocesses), as the scripts are now part of the gotran package.