Skip to content

Commit d7559ff

Browse files
committed
verify an argument is correct using api_version() instead of isinstance()
1 parent 613f2ad commit d7559ff

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pyomo/gdp/plugins/multiple_bigm.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from pyomo.common.gc_manager import PauseGC
2828
from pyomo.common.modeling import unique_component_name
2929
from pyomo.common.dependencies import dill, dill_available, multiprocessing
30+
from pyomo.common.enums import SolverAPIVersion
3031

3132
from pyomo.core import (
3233
Block,
@@ -54,8 +55,6 @@
5455
from pyomo.gdp.plugins.gdp_to_mip_transformation import GDP_to_MIP_Transformation
5556
from pyomo.gdp.util import _to_dict
5657
from pyomo.opt import SolverFactory, TerminationCondition
57-
from pyomo.contrib.solver.common.base import SolverBase as NewSolverBase
58-
from pyomo.contrib.solver.common.base import LegacySolverWrapper
5958
from pyomo.repn import generate_standard_repn
6059

6160
from weakref import ref as weakref_ref
@@ -92,11 +91,8 @@ def Solver(val):
9291
return SolverFactory(val)
9392
if not hasattr(val, 'solve'):
9493
raise ValueError("Expected a string or solver object (with solve() method)")
95-
if isinstance(val, NewSolverBase) and not isinstance(val, LegacySolverWrapper):
96-
raise ValueError(
97-
"Please pass an old-style solver object, using the "
98-
"LegacySolverWrapper mechanism if necessary."
99-
)
94+
if not hasattr(val, 'api_version') or val.api_version() is not SolverAPIVersion.V1:
95+
raise ValueError("Solver object should support the V1 solver API version")
10096
return val
10197

10298

0 commit comments

Comments
 (0)