New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Use highspy in linprog
#19255
base: main
Are you sure you want to change the base?
ENH: Use highspy in linprog
#19255
Conversation
|
Also @mckib2 if you'd like to take a look that'd be great (or maybe after its out of draft status). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's here looks good - lots of complexity gets removed. Hard to say more because an essential bit - actually building highspy as part of the SciPy build - seems to be missing.
abe6bac
to
68b5bdf
Compare
|
This is almost done, except the build process on the SciPy CI is stricter than over at HiGHs (w.r.t warnings) so some more work is required. |
|
You can silence classes of warnings by adding defining them (if they're not already present) here: Lines 287 to 300 in 21dcad2
and then adding them to |
|
It'd still be nice to get them fixed upstream, but that shouldn't be blocking for finalizing this PR. |
d855fa0
to
b3f3cc2
Compare
Thanks that helped, but I'm not sure of the best approach for the rest, it seems like using a shared library ends up with (expected) lookup errors, but the static library fails the wheel build. In both cases there's a too many public symbols error. ../build/subprojects/highs/highspy/_highs_options.cpython-310-x86_64-linux-gnu.so: too many public symbols!
000000000000d980 T PyInit__highs_options
0000000000031570 T _Z10first_wordRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi
0000000000031240 T _Z10strToLowerPc
000000000002df90 T _Z11checkOptionRK15HighsLogOptionsRK15OptionRecordInt
000000000002e050 T _Z11checkOptionRK15HighsLogOptionsRK18OptionRecordDouble
000000000002cca0 T _Z11highsLogDevRK15HighsLogOptions12HighsLogTypePKcz
000000000002e130 T _Z12checkOptionsRK15HighsLogOptionsRKSt6vectorIP12OptionRecordSaIS4_EE
000000000002c8f0 T _Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz
0000000000030290 T _Z12reportOptionP8_IO_FILERK15OptionRecordIntb13HighsFileType
000000000002fe00 T _Z12reportOptionP8_IO_FILERK16OptionRecordBoolb13HighsFileType
00000000000[30](https://github.com/scipy/scipy/actions/runs/6372457292/job/17295259302?pr=19255#step:11:31)660 T _Z12reportOptionP8_IO_FILERK18OptionRecordDoubleb13HighsFileType
0000000000030a90 T _Z12reportOptionP8_IO_FILERK18OptionRecordStringb13HighsFileType
0000000000030e90 T _Z13reportOptionsP8_IO_FILERKSt6vectorIP12OptionRecordSaIS3_EEb13HighsFileType
000000000002dc40 T _Z14boolFromStringNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERb
00000000000[31](https://github.com/scipy/scipy/actions/runs/6372457292/job/17295259302?pr=19255#step:11:32)4b0 T _Z14first_word_endRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi
000000000002dd40 T
...What is the best approach to dealing with libraries which (ideally) should be installed by the user? OR, I'm missing something about the way the static library should be linked, since other sub-libraries are linked statically ( |
|
The current version seems quite close to ready, modulo the use of a wrap file (I assume that's for convenience during development, and it'll change to a git submodule at the end) and this error: The static library linking looks fine here, the only problem is that the To make that the default behavior, add this to [tool.meson-python.args]
install = ['--skip-subprojects'] |
|
Note that that feature does require Meson 1.2.0, so you should bump the minimum version in the top-level |
|
Thanks @rgommers, I'll get to updating this in a few days but:
I was thinking we ought to keep it as a submodule? It should change to point to the Scipy/Highs instead of my own but other than that it would make more sense to keep the meson-first subproject approach. The only issue I can think of is that the The way the build is structured now, the subproject defines all the necessary variables (including the files needed), which means we would very rarely need to update the Perhaps @eli-schwartz has more comments on submodules v/s subprojects? |
|
Using it as a subproject is very much preferable. You get component isolation: it's not SciPy's job to be concerned about how highs gets built, you just want to automatically use whatever the highs subproject does to define its static-library artifact(s), and then you consume them. This also unlocks the ability to switch from: highs_proj = subproject('highs', ......to highs_proj = dependency('highs')along with specifying in SciPy, This would allow downstream builders (especially linux distros) the option to build highs as an external package and then build SciPy against that. But people doing |
|
That all sounds right - I didn't mean a git submodule instead of a subproject. Rather, I meant that I'm missing a git submodule under
Yes, that is what I had in mind as well. |
|
Whether to use subprojects via a wrap file or a git submodule (or both at the same time!) is largely unimportant as far as meson is concerned. The main thing that strikes me about the topic is that git submodules tend to be larger to download than a tarball, and, if you create "light" sdists that only download the subprojects with an online build when the person building the wheel hasn't disabled the use of subprojects, the tarball version works without git installed, while the submodule requires installing git. I think both options are defensible choices, but adding a meson subproject as a git submodule will probably be more pleasant for you if you expect most people to interact with the source code via git using long-running clones, distribute sdists with subprojects included, and don't support GitHub autogenerated tag tarballs at all... ... which are all qualities that SciPy has. |
|
Thanks, that explains it. Then I had the right thing in mind:
The wrap file is indeed nicer now, when you're developing this PR while making fixes to HiGHS as well. And once it's done, you can swap the wrap file for a git submodule under |
703fc8e
to
76e3fb7
Compare
|
Failures seem unrelated ( |
+1 for this. I haven't forgotten about this PR, it was just a busy period + holiday season. Planning to get this reviewed this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very close. A few comments inline - all minor.
The silencing of unused variable warnings didn't work, because they're coming from the static library built within subprojects/highs:
[6/11] Compiling C++ object subprojects/highs/src/libhighs.a.p/lp_data_HighsSolve.cpp.o
../subprojects/highs/src/lp_data/HighsSolve.cpp:48:10: warning: unused variable 'imprecise_solution' [-Wunused-variable]
bool imprecise_solution;
^
../subprojects/highs/src/l
Looks like those should be fixed upstream, and perhaps silenced in our forked repo in the meantime.
There are also a couple of other warnings. In the build:
ld: warning: ignoring duplicate libraries: '-lc++'
and in the configure stage:
highs| subprojects/highs/meson.build:16: WARNING: add_languages is missing native:, assuming languages are wanted for both host and build.
I'm seeing a number of other issues in highs/meson.build (mainly with compiler-specific flags that aren't check) that are likely to be a problem, so let me open a PR for those upstream.
I'll push a rebase to fix the conflict and get a fresh CI run.
subprojects/highs.wrap
Outdated
| [wrap-git] | ||
| url = https://github.com/scipy/highs.git | ||
| revision = a0df06fb20f2c67c02cf84d8a3b72862c2ab2b27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works as intended it looks like; it basically checks out the git submodule automatically. The one minor issue is that it leaves behind an extra file:
subprojects/highs/.meson-subproject-wrap-hash.txt
If that's added to .gitignore then I think we're all good here.
subprojects/highs.wrap
Outdated
| [wrap-git] | ||
| url = https://github.com/scipy/highs.git | ||
| revision = a0df06fb20f2c67c02cf84d8a3b72862c2ab2b27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not actually true it seems - when building an sdist after using the auto-checkout-via-wrapfile, I see:
WARNING: Submodule 'subprojects/highs' is not checked out and cannot be added to the dist
So you still need to run:
$ git submodule update --init
Submodule 'subprojects/highs' (https://github.com/scipy/highs) registered for path 'subprojects/highs'
That is then instant. But the annoying thing is that git status no longer tells you that you've missed a step. You've got the right checkout, but haven't "connected" it as a submodule. Nothing much goes wrong though as far as I can tell, it's just a little weird.
|
The linter is unhappy - the |
|
One other key thing here that I am still reviewing/testing more carefully is that with the use as a subproject, we get extra constraints from the upstream
So this isn't as close as I thought yet. I'd really like for our fork of highs not to diverge from upstream, so let's see how easy it is to patch things up there first. |
Thanks for the comprehensive review and comments @rgommers, I'll address these both upstream and here this weekend. |
ENH: Rework _linprog_highs to use highspy Still needs a wrapper around Highs() MAINT: Refactor slightly and add commit credit Co-authored-by: mckib2 <mckib2@users.noreply.github.com> ENH: Use highspy exclusively TST: Almost pass everything MAINT,TMP: Use my highs until merge
MAINT: Minor renaming for the modeling API BLD: Rework to use highs as a subproject MAINT: Remove highs submodule and rework
ENH: Use highs_options TST: Fixup tests MAINT: Update to commit with no build warnings MAINT: Try building without errors MAINT: No static libraries.. MAINT: Try static again, move meson files around MAINT: Use an internally built highspy MAINT: Update to latest highspy With fixes as suggested Co-authored-by: rgommers <rgommers@users.noreply.github.com> BLD: Use variables defined by scipy BLD: Skip subproject installation Co-authored-by: rgommers <rgommers@users.noreply.github.com> MAINT: Provide link_args for highspy MAINT: Cleanup with newer API [highspy] MAINT: Cleanup to prevent building highspy ... outside of scipy at any rate MAINT: Update to streamlined highspy api TST: Revert changes to testsuite [linprog] Remain 100% backwards compatible
TST: Revert changes to milp tests MAINT: Quiet mypy problems w.r.t highspy MAINT: Fix typo in documentation Fixes the refguide check, the primal status for an infeasible problem is None TST: Rework the one test which returns new results BLD: Rework to include scipygh-17777 for highs MAINT: Rework to a minimal highspy subset MAINT: Try to disable highsint64 for 32-bit fix MAINT: Update pyproject for more meson-python args BLD: Try to conditionally build with highsint64 MAINT: Add back a submodule (personal) MAINT: Update the wrap file MAINT: Simplify pyproject for now MAINT: Simplify highs_defaults upstream
MAINT: Switch to the scipy fork of highs TST: xfail known flaky test Co-authored-by: mckib2 <mckib2@users.noreply.github.com> MAINT: Add a note on .gitmodule location Co-authored-by: h-vetinari <h-vetinari@users.noreply.github.com>
Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
Co-authored-by: rgommers <rgommers@users.noreply.github.com>
|
@rgommers I've addressed the issues raised on a PR to HiGHS here (sorry for the delay): Beyond that I've made a few cosmetic changes (rolling back
|
|
Failing tests seem unrelated: |
Supersedes #18642.
Reference issue
Closes #15915. Closes #15888. Closes #19734.
What does this implement/fix?
linprogCython bindings with upstreamhighspyTests pass (locally anyway). However, there are still plenty of improvements which can be made (once
highspyworks a bit more robustly ERGO-Code/HiGHS#1405)Additional information
Needs a PR over at
highs(ERGO-Code/HiGHS#1460) and over at the SciPy fork (scipy/HiGHS#63).Draft status until:
[ ] Changes merged upstream in a new PyPI releaseUnrelatedscipyfork ofhighs