Page 1 of 1

Python API: Catching Warnings

Posted: Tue Jan 16, 2024 11:48 am
by Jan
Hello,

I wonder wether it is possible to catch warning coming from the GAMS API in Python. They are meaningful and I see that they should be respected. But sometimes we are aware of the reasons and want to disregard them for the moment, in particular in running loops over several model runs. One example is the warning about version inconsistencies between the installed gams version and the one installed via pip.

The problem seems to be that these warnings are not implement as Warning from the python module but as print statements and therefore cannot be catched. Is there any solution to that (yes I know, work with consistent version...)?

Many thanks and best
Jan

Re: Python API: Catching Warnings

Posted: Wed May 08, 2024 5:11 pm
by Clemens
Jan,

We did change the implementation of those warnings in the Python Control API to use the warnings module instead of print(). This will become available with the next major release of GAMS.

Best,
Clemens