sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.41k stars 475 forks source link

Failing tests when using system glpk #29493

Closed kliem closed 4 years ago

kliem commented 4 years ago

At the moment there are two failing doctests, when using the glpk from the system, e.g. on ubuntu eoan https://github.com/mkoeppe/sage/runs/542655821

sage -t src/sage/numerical/backends/glpk_backend.pyx
**********************************************************************
File "src/sage/numerical/backends/glpk_backend.pyx", line 2287, in sage.numerical.backends.glpk_backend.GLPKBackend.print_ranges
Failed example:
    p.print_ranges()
Expected:
    glp_print_ranges: optimal basic solution required
    1
Got:
    1

This doctest was mentioned before in #29317 with a suggestion for a fix.

 sage -t src/sage/libs/glpk/error.pyx
**********************************************************************
File "src/sage/libs/glpk/error.pyx", line 100, in sage.libs.glpk.error.setup_glpk_error_handler
Failed example:
    res = p.solve()
Expected:
          0: obj = ...
Got:
    <BLANKLINE>

The problem is that we have doctests that rely on error-recovery behavior added by a custom patch [#20710 comment:18], which wasn't accepted by upstream. (The doctest for the patch was added in #20832.)

The present ticket fixes the failures by

CC: @jdemeyer @mkoeppe @orlitzky @jpflori @embray @sagetrac-gouezel @kiwifb @dcoudert @dimpase

Component: packages: standard

Keywords: glpk, patches

Author: Michael Orlitzky, Matthias Koeppe

Branch/Commit: 8acdf34

Reviewer: Matthias Koeppe, Michael Orlitzky

Issue created by migration from https://trac.sagemath.org/ticket/29493

mkoeppe commented 4 years ago

Reviewer: Matthias Koeppe, ...

mkoeppe commented 4 years ago
comment:46

Tests run at https://github.com/mkoeppe/sage/actions/runs/129317169

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

9427aa1src/sage/libs/glpk/error.pyx: Fixup doctest markup
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 066b1e8 to 9427aa1

mkoeppe commented 4 years ago
comment:48

New test at https://github.com/mkoeppe/sage/runs/755764195

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

28024acsrc/sage/libs/glpk/error.pyx: Make doctest more flexible
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 9427aa1 to 28024ac

mkoeppe commented 4 years ago
comment:50

New tests at https://github.com/mkoeppe/sage/actions/runs/130367945

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

8acdf34Fixup doctest
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 28024ac to 8acdf34

mkoeppe commented 4 years ago
comment:52

Passes tests now - see for example https://github.com/mkoeppe/sage/runs/756778388

mkoeppe commented 4 years ago
comment:53

I have also tested with https://github.com/mkoeppe/sage-numerical-interactive-mip (which uses some of these methods).

I would be ready to set it to positive_review; but we need another reviewer for my (trivial) changes.

orlitzky commented 4 years ago
comment:55
+    We install this error handler so that an error does not lead to
+    an immediate error exit of the process.  Instead, we raise a
+    ``GLPKError`` for the convenience of developers.

The sage process never exited, but the error left GLPK unusable from that point forward -- for example returning nothing instead of solving subsequent problems as in the ticket description. The error handler itself is fine; it's toggling the "there was an error" bit off afterwards that's causing all this trouble.

I still think it's perverse to leave around 150 lines of code with a docstring that says "don't use this," but where we are is not even locally optimal, so let's just do it.

mkoeppe commented 4 years ago
comment:56

Replying to @orlitzky:

150 lines of code with a docstring that says "don't use this,"

... "for production".

orlitzky commented 4 years ago

Changed reviewer from Matthias Koeppe, ... to Matthias Koeppe, Michael Orlitzky

kliem commented 4 years ago
comment:58

Thank you for doing this.

vbraun commented 4 years ago

Changed branch from u/mkoeppe/ticket/29493 to 8acdf34