-
Notifications
You must be signed in to change notification settings - Fork 250
Closed
Labels
stalestale issue/PR as determined by actions botstale issue/PR as determined by actions bot
Description
Motivation or Problem
When VSCode/PyCharm are being used to debug RMG-Py, the execution of the code during the debug process will suddenly stop without reporting the exception. The exception will only be reported if the user ticks the 'User Uncaught Exceptions'/'Raise Exceptions' in the 'BREAKPOINTS' section. The issue is that during the debugging process there is a few lines of code it fails
File: reactors.py
try:
from pyrms import rms
from diffeqpy import de
from julia import Main
except:
passThe reported error is 'ModuleNotFoundError' for 'pyrms'
Desired Solution
This error can be rectified a couple of ways:
- Modify the except statement to include 'ModuleNotFoundError'
- Check if in debug mode
import sys
gettrace = getattr(sys, 'gettrace', None)
if gettrace is None:
try:
from pyrms import rms
from diffeqpy import de
from julia import Main
except:
pass
elif gettrace():
###Run Alternative pyrms/diffeqpy load as explained in point 3- Import pyrms and diffeqpy modification
elif gettrace():
from julia.api import Julia
jl=Julia(compiled_modules=False)
from pyrms import rms
from diffeqpy import de
from julia import Main- Improve the loading of RMS - PyJulia has the ability to create a system image as
*.sysfile. This will improve the load time of RMS. However, it will require updating PyJulia to version 0.6.0 (right now RMG uses PyJulia - 0.5.3)
python -m julia.sysimage sys.soNow assuming the system image, named sys.so (can be changed of course), has been created - then changes to importing Jula from julia.api will be required.
from julia.api import Julia
jl=Julia(sysimage="sys.so") #This may need modification to also include the path- If point four is followed through, then creating of the system image can be part of the installation of RMG-Py for the Source instructions.
Full Solution
import sys
gettrace=getattr(sys, 'gettrace', None)
if gettrace is None:
try:
from pyrms import rms
from diffeqpy import de
from julia import Main
except ModuleNotFoundError:
pass
elif gettrace():
try:
from os.path import dirname, abspath, join
path_rms = dirname(dirname(dirname(abspath(__file__))))
from julia.api import Julia
jl = Julia(sysimage=join(path_rms,"sys.so"))
from pyrms import rms
from diffeqpy import de
from julia import Main
except:
from julia.api import Julia
jl = Julia(compiled_modules=False)
from pyrms import rms
from diffeqpy import de
from julia import MainMetadata
Metadata
Assignees
Labels
stalestale issue/PR as determined by actions botstale issue/PR as determined by actions bot