[Xpress] Remove deprecation warnings (#1)#3794
Conversation
* TXP-7757: removed most deprecation warnings up to current unpublished release * Fixed more warnings * Missing version agnostic functions * Fixed version specific LPStatus enums + renamed get-lb/ub methods * Suggested improvements
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3794 +/- ##
==========================================
- Coverage 89.48% 89.47% -0.01%
==========================================
Files 904 904
Lines 105385 105474 +89
==========================================
+ Hits 94299 94377 +78
- Misses 11086 11097 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| PYVER=$(echo "py${{matrix.python}}" | sed 's/\.//g') | ||
| echo "Installing for $PYVER" | ||
| for PKG in 'cplex>=12.10' docplex gurobi "$XPRESS" cyipopt pymumps scip; do | ||
| for PKG in 'cplex>=12.10' docplex gurobi "$XPRESS" 'xpress<9.3' cyipopt pymumps scip; do |
There was a problem hiding this comment.
This is changing the xpress version for every GHA job using conda to install Python packages which is not what I think you intended. During the dev call we talked about installing an older version of xpress on just one or two jobs to exercise the version-specific logic in the solver interface. I think you can do this by modifying the if-tree above that sets the XPRESS environment variable. There is already some special logic there for windows so maybe we use the linux conda job for this. I think you can just modify the else section on line 450 to something like:
if test "${{matrix.TARGET}}" == linux; then
XPRESS='xpress<9.3'
else
XPRESS='xpress'
fi
There was a problem hiding this comment.
Sorry, I should have asked for clarification during the call!
I've applied the changes, targeting Python 3.10 so the latest Xpress release is still tested in the other jobs. Let me know if there are any other issues.
There was a problem hiding this comment.
So turns out we can't use the Linux conda job to test an older version of Xpress because we can't get ANY version of Xpress to install in our Linux/conda GHA job. I tried both Python 3.11 and 3.12. They fail saying the environment can't be satisfied because intel-openmp can't be found in our conda channels. I modified the workflow to try using the win/3.10 and win/3.11 jobs instead.
There was a problem hiding this comment.
Thank you, Bethany. Let me know if there is anything I could do to help!
There was a problem hiding this comment.
Our conda environments are fragile on GHA so I switched to using the linux/3.10 and linux/3.11 jobs for this which install Xpress using pip. I'll mark this discussion as resolved once I verify that the right versions of Xpress were installed.
|
@XPRSc4v4 unfortunately, I don't think there is a way to test an "old enough" version of Xpress to cover the version-based if-tree in the interface using our GHA infrastructure. Asking for If you agree with my assessment then I think we should revert the changes to the GHA workflow and accept the slight decrease in coverage. |
|
I agree, it would have been nice to have coverage for those compatibility branches, but not at the expense of complicating the test environment. The slight decrease in coverage is fine. Thanks for looking into this! |
Removed conditional installation for older Xpress version.
jsiirola
left a comment
There was a problem hiding this comment.
Overall this seems OK. I do have one suggestion that might simplify things (wrap the Xpress model class instead of adding a bunch of private dynamic functions on the Pyomo solver interface):
| ComponentMap.hasher.hashable(xpress.var, False) | ||
| ComponentMap.hasher.hashable(xp.var, False) | ||
|
|
||
| # Xpress 9.8 (46) adopted camelcase function naming, deprecating the old names |
There was a problem hiding this comment.
Instead of creating all these function pointers for both old and new Xpress, would it be simpler and more clear to create an Xpress45Problem wrapper class that would wrap an old-style problem instance and support both the old-style and new-style interfaces? Something like:
class Xpress45Problem:
def __init__(self, prob):
super().__setattr__(self, '_wrapped_problem', prob)
def __getattr__(self, name):
# The new API is camelCase, whereas the old interface was
# all lowercase: try the new API and fall back on all lowercase:
try:
return getattr(self._wrapped_problem, name)
except AttributeError:
return getattr(self._wrapped_problem, name.lower())
def __setattr__(self, name, val):
return setattr(self._wrapped_problem, name, val)
'setLogFile': 'setlogfile',
'lpOptimize'
Hi!
Fixes
Summary/Motivation:
Starting with Xpress 9.8 (Python API version 46), FICO deprecated lowercase function names in favor of camelCase (e.g.,
lpoptimize→lpOptimize) and removed several enum types. The old functions are still available but deprecated, and will be removed in future releases. This PR adds runtime version detection to dispatch to the correct functions and enums based on the installed Xpress version, eliminating deprecation warnings while maintaining backward compatibility.Changes proposed in this PR:
XpressDirectinterface instead of calling Xpress Python APIs directlyLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: