Skip to content

Commit fbe1a83

Browse files
committed
Import was happening unconditionally
1 parent 38f73d3 commit fbe1a83

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

pyomo/contrib/solver/solvers/xpress/xpress_base.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
UnaryFunctionExpression,
7171
)
7272
from pyomo.core.expr.visitor import StreamBasedExpressionVisitor
73-
from pyomo.core.expr import native_numeric_types
7473
from pyomo.core.base import Expression as NamedExpressionComponent
7574
from pyomo.core.expr.numvalue import value
7675
from pyomo.common.gc_manager import PauseGC
@@ -198,14 +197,11 @@ def xp_cb(*vals):
198197
return xp.user(xp_cb, *xp_args, derivatives="always" if has_grad else "never")
199198

200199

201-
def _init_xpress() -> tuple:
200+
def _init_xpress(xp, xpress_available):
202201
"""Populate all Pyomo<->Xpress entity maps. No-op if already done or if
203202
xpress did not import successfully."""
204-
205-
xp, xpress_available = attempt_import('xpress', catch_exceptions=(Exception,))
206-
207203
if not xpress_available:
208-
return xp, xpress_available
204+
return
209205

210206
_VAR_XP_TYPE_MAP.update(
211207
{
@@ -302,10 +298,8 @@ def _init_xpress() -> tuple:
302298
}
303299
)
304300

305-
return xp, xpress_available
306-
307301

308-
xp, xpress_available = _init_xpress()
302+
xp, xpress_available = attempt_import('xpress', callback=_init_xpress)
309303

310304

311305
def _register_pool_collector(prob, pool_limit: int) -> 'list[list[float]]':

0 commit comments

Comments
 (0)