iiasa / ixmp

The ix modeling platform for integrated and cross-cutting scenario analysis
https://docs.messageix.org/ixmp
Apache License 2.0
38 stars 112 forks source link

Improve error messages on GAMS errors #383

Closed khaeru closed 3 years ago

khaeru commented 4 years ago

When GAMS fails to execute (due to configuration errors, model coding errors, etc.), the traceback ends with, e.g.

>           raise CalledProcessError(retcode, cmd)
E           subprocess.CalledProcessError: Command 'gams "c:\users\username\documents\github\message_ix\message_ix\model\MESSAGE_run.gms"
--in="c:\users\username\documents\github\message_ix\message_ix\model\data\MsgData_message_data_test_message_data.gdx"
--out="c:\users\username\documents\github\message_ix\message_ix\model\output\MsgOutput_message_data_test_message_data.gdx"
--iter="c:\users\username\documents\github\message_ix\message_ix\model\output\MsgIterationReport_message_data_test_message_data.gdx" LogOption=4' returned non-zero exit status 3.
C:\ProgramData\Anaconda3\lib\subprocess.py:364: CalledProcessError

This can be cryptic, and isn't useful when reported in an issue. To improve, it should read something like:

ixmp.SolveError: The model failed to solve.

Further information may be available in the file:
c:\users\username\documents\github\message_ix\message_ix\model\MESSAGE_run.lst

The GAMS exit status could also be translated from this table.

This way, the user could (a) find and look at the listing file, or (b) attach it to a bug or issue report.