2

Is there a way to get the return code from running a GamsJob in the GAMS Python API? Meaning, after I do job.run(), is the return code from this execution stored somewhere I can access?

2 Answers2

2

job.run() will throw an exception with the return code stored in the attribute .rc if the return code is non-zero. Therefore:

try:
    job.run()
except GamsExceptionExecution as e:
    print(e.rc)  # This is a non-zero return code
jebob
  • 173
  • 12
1

The return code should be in the same folder as the run file.

For instance, with the transport1.py example detailed here https://gams.com/latest/docs/apis/examples_python/index.html, you can find the .lst file as follows:

  • t1._file_name gives you a "PATH\transport.gms" (where transport.gms is the file defining the model to run)
  • t1._job_name gives you the job name
  • from there: PATH\t1._job_name.lst is the lst file, as follows:

    os.path.dirname(t1._file_name)+"\\"+t1._job_name+".lst"
    
Jon
  • 351
  • 2
  • 10