Closed TongZhai closed 4 years ago
@michaeltryby we are refocusing on this important issue. I've stepped through the debugging process of running the example SWMM models and it is still not clear the exact cause of this behavior. What's certain in all cases is that the model simulations seem to be completed and the call to swmm_close() returns error code of 0 (indicating success), then it dies in the output api instantiation process (i.e. SMOutputSWIG.py->SwmmOutputObject.__init__()
). Specifically, it failed in the output.py->init()
or output.py->open()
calls. I am not familiar with the debugging process you used in testing these example SWMM models, could you elaborate a bit more and let's see if we can work out a process so that you can reproduce this behavior within the context of this program. On another point, I know last time we had a discussion about the timing of accessing the output file right after the simulation, I think this is how the original Delphi version function to retrieve output to populate output display elements in the UI such as the animation display listing etc and this scheme indeed works on some models in the new program.
I also constructed a src\ui\SWMM\Test_Run_SWMM.py
script that you can use to run SWMM model using our libraries directly without using the interface. To use it, please first change this line in the core.inp_reader_base.py->set_from_text_lines()
:
winform = True
--change to--> winform = False
Let's start the debugging of this puzzling bug.
@TongZhai I worked on this issue today and made some progress. I fixed a bug in getunits()
that was causing the dll to crash. I will try to push out a new version of the package in the next hour otherwise on Monday.
@TongZhai new packages can be found here
@michaeltryby just tested the new version (swmm.output-0.4.0.dev2-cp37-cp37m-win_amd64) of the swmm.output api, it is now able to handle the previously failed Example 2, 5, and 6 models, without crashing the software. I will run a few more tests, seems this is resolved.
Testing shows the updated swmm output api indeed resolved the run failure involving some sample swmm models. The wiki page on how to setup development environment in python 3 is updated, pointing to this updated version of swmm output api.
@michaeltryby just run into problem packaging this new swmm.output lib into the installation package. Now the compiled package version keeps saying the following:
exec(bytecode, module.__dict__)
File "Externals\swmm\outputapi\SMOutputSWIG.py", line 7, in <module>
File "C:\OSGeo4W64\apps\Python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\swmm\output\__init__.py", line 34, in <module>
File "C:\OSGeo4W64\apps\Python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\swmm\output\output.py", line 18, in <module>
File "site-packages\swmm\output\output.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 127, in import_module
ModuleNotFoundError: No module named 'swmm.output._output'
[24124] Failed to execute script frmMainSWMM
Specifically, in the SMOutputSWIG.py, the swmm.output api is imported as below:
from swmm.output import output as _lib
this works in the development environment, but fails in package. Has the namespaces in the output api changed in this new version?
The swmm.output
package consists of the following files:
__init__.py, _outputcp37-win_amd64.pyd, output.py, and swmm-output.dll
ModuleNotFoundError: No module named 'swmm.output._output
The exception leads me to believe that the _output*.pyd
is missing from the installer package or can't be found on the python path for some reason.
@michaeltryby that makes sense. I double-checked that the _output.cp37-win_amd64.pyd
from the install directory (c:\osgeo4w64\apps\Python37\Lib\site-packages\swmm\output\
) was indeed copied into the package directory, as it was in previous packages.
@TongZhai I don't know if this makes a difference, but in the previous version of the output API swmm-output.dll
was compiled into _output*.pyd
. But in this version they are linked. So they need to find each other at run time or it's not going to work.
@TongZhai also its organized as an implicit namespace package. Maybe the installer has problems dealing with those.
@TongZhai Try making the path to the files swmm\output\
in the install package and see if it works.
Meant to say swmm.
@michaeltryby thanks for the instruction, after putting swmm output api libraries into the swmm\output\ folder in the package directory, it can find the output api now after packaging
This is an reoccurring issue at this point. SWMM engine version is updated to the latest 5.10.13 version. The output API is also updated to the latest.
Symptom: Running standard Example models 2, 5, and 6 simulation will complete, but subsequent output access will cause the program to quit.
version of swmm dll downloaded from: https://github.com/USEPA/Stormwater-Management-Model/releases/tag/v5.1.13 swmm-solver-5.1.13-win64.zip
swmm-output.dll: https://github.com/OpenWaterAnalytics/swmm-python/releases swmm.output-0.4.0.dev1-cp37-cp37m-win_amd64.whl