Skip to content

Remove tropter #3988

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

Merged
merged 19 commits into from
Feb 27, 2025
Merged

Remove tropter #3988

merged 19 commits into from
Feb 27, 2025

Conversation

aymanhab
Copy link
Member

@aymanhab aymanhab commented Jan 13, 2025

Fixes issue opensim-org/opensim-gui#1533

Brief summary of changes

Remove the tropter library, MocoTropterSolver, and all references to Tropter in the tests, documentation, examples, etc. As a result, the following dependencies has been removed: eigen, adolc, and colpack.

Tropter is only very minimally used compared to CasADi in Moco, so we've decided that the burden to support Tropter and its dependencies is not worth our development effort going forward. Additionally, these changes will open the door to more efficient implementation of Moco's direct collocation libraries that could leverage CasADi's automatic differentiation tools.

Testing I've completed

Ran test suite.

Looking for feedback on...

Currently, the Python tests are failing on Windows CI. These test pass locally, it is unclear why they fail in the Windows GitHub Actions runners.

CHANGELOG.md (choose one)

  • updated.

This change is Reviewable

@nickbianco
Copy link
Member

Hey @aymanhab, I just noticed you started working on this. I think I misunderstood your message from last week; I was under the impression that you were going to disable the test suite for tropter when building the conda packages, and not remove them directly here. I was hoping to address all the tropter changes at once (i.e., remove the tropter libraries and the tests together). I'm a bit hesitant to gut out the tests while the tropter solver still exists as an option.

Is there a way to build the conda packages without tropter for now (i.e., by setting the OPENSIM_WITH_TROPTER flag)?

@aymanhab
Copy link
Member Author

No problem @nickbianco I actually have a conda package without tropter using the cmake option already (https://anaconda.org/opensim_admin/opensim/files)
I removed the tests from the tree on a branch to make sure there're no side effects on MocoTests since that's the most entangled piece, and I started removing the actual cmake flags. I agree they should all go together (tests and code removal). You can take the branch over if you want.

@aymanhab
Copy link
Member Author

@nickbianco I went ahead and removed references to tropter from the build system and ci, and the last remaining piece is that some python tests in test_moco.py are failing because they were using tropter without checking if available

self.assertAlmostEqual(sol.getParameter("sphere_mass") + sol.getParameter("sphere2_mass"),

When you have a chance let me know if I should remove some/all of these tests that use tropter or convert to casadi

Thank you

@nickbianco
Copy link
Member

@aymanhab it would be best to keep those tests and convert them all to use MocoCasADiSolver. All usages of initTropterSolver can be replaced with initCasADiSolver.

Were you planning on removing the tropter libraries as part of this PR too?

@aymanhab
Copy link
Member Author

@nickbianco My plan was to make the build/install/test all work first and removed from the make system on this branch and then remove the folders (in case something comes up that force a backtrack) but it can go in any order. Do you expect any results to change when swapping the solvers?

@nickbianco
Copy link
Member

That sounds like a good plan. Theoretically, the tests should pass with either solver, but it's possible that differences in each implementation could lead to different numerical results. I'm happy to debug any such cases that arise.

We will also need to eventually remove Tropter from all of the tests under the Moco test folder.

@aymanhab
Copy link
Member Author

@nickbianco I'll pass this on to you to do the internal cleanup of the Moco tests. The python test cases pass on linux but not on windows or osx though the failures are for reasons unrelated to this PR as far as I can tell. Just let me know if you want me to investigate these failures. Thank you.

@nickbianco
Copy link
Member

Sure @aymanhab. I'll pick this up starting next week.

@aymanhab
Copy link
Member Author

Thanks @nickbianco 👍
Something to keep in mind when looking into test failures, the moco python tests with casadi all succeed when run from dev/build environment directly but fail when run from install environments on windows/mac

@nickbianco nickbianco changed the title Remove tropter test cases and make sure all tests pass with casadi Remove tropter Feb 12, 2025
@nickbianco nickbianco marked this pull request as draft February 12, 2025 21:54
@nickbianco
Copy link
Member

@aymanhab, the scripting tests were failing because the Ipopt libs were no longer being copied into the install directory. I've fixed this for Mac; now I'm trying to figure out where the copy was previously happening for Windows.

I also preemptively updated the CMake files to carry over the rpaths needed for CasADi on Linux (which somehow ended up in tropter's directory). I think these rpaths were mainly needed for the conda packages? Maybe you could take a look at the latest commits to see if it makes sense to you.

@aymanhab
Copy link
Member Author

aymanhab commented Feb 12, 2025

OpenSimCopyDependencyDLLsForWin(DEP_NAME casadi

This copies casadi, as to ipopt and other dependencies they're copied later at the same file under ipopt block

@aymanhab
Copy link
Member Author

@nickbianco Conda does its own rpath setting since it has a different layout so don't worry about it and let's get the installation to be self contained regardless of conda

@nickbianco
Copy link
Member

Sounds good @aymanhab. I think the issue on Windows has to do with one of the Ipopt dependencies being missing in the install directory, but I will continue to investigate.

@nickbianco nickbianco marked this pull request as ready for review February 19, 2025 18:20
@nickbianco
Copy link
Member

@aymanhab, I finished cleaning up all references to Tropter in the documentation. The last thing for you to look over are the changes I made releated to RPaths, i.e., OpenSimMocoInstallLinuxDependencyLibraries.cmake.

Copy link
Member Author

@aymanhab aymanhab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickbianco The only material change I saw was in a message, so :lgtm:

Reviewable status: 0 of 176 files reviewed, all discussions resolved

@nickbianco
Copy link
Member

@aymanhab, just to clarify, OpenSimMocoInstallLinuxDependencyLibraries is a completely new file in this PR (I added it a few commits ago).

Also, should we get another reviewer? This is a pretty big change.

@aymanhab
Copy link
Member Author

@nickbianco It wouldn't hurt to get another pair of eyes though the number of files is intimidating. Primarily I'd clarify that this PR is gutting out Tropter as a Moco solver from the codebase/build-system so no new functionality is added/tested.

For the make files, I glanced over them and looked like they were moved rather than rewritten, and they looked fine. Though taking a second look now I realize that the names of the libraries have changed a while ago (on mac/linux there's no coinmetis, only metis)

@nickbianco
Copy link
Member

@carmichaelong, tagging you for a review here. It is a huge PR, but the vast majority of changes are removed files and code. The changes to the build system are the main things that should be removed.

@adamkewley also tagging you here as an FYI. Just in case you wanted to take a look at (and maybe review, if you're feeling generous) the changes to the build system and make a note of anything that might affect OpenSim Creator downstream. Hopefully, the removal of the dependencies should make things simpler on your end (although I'm not sure you build those dependencies in the first place).

if(UNIX)
pkg_check_modules(IPOPT REQUIRED ipopt IMPORTED_TARGET)

if(OPENSIM_COPY_DEPENDENCIES AND APPLE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, of the changes, these additions are the ones that make me go hmmmmm.

It looks like you're trying to tell cmake to add those libraries as runtime libraries to the installation set. Fair enough, but cmake has functions specifically for doing this, such as install(TARGETS libOsimMoco RUNTIME_DEPENDENCIES).

If cmake's dependency resolution mechanisms don't work, it's usually a sign that your library targets (i.e. the things passed to target_link_libraries) aren't declaring which files are dependent on which. Do as you wish, but the way this is written right now smells fishy (e.g. it won't work if the Linux target architecture is changed from x86_64, or if it's ran on a distribution of Linux that has a different sys library directory layout).

@adamkewley
Copy link
Contributor

Other than the single comment, which you can take or leave (because I'm not planning on compiling moco: its dependency tree is still too big relative to the payoff in OSC), looks good - I'm generally a fan of dropping dependencies 😉

@aymanhab
Copy link
Member Author

@adamkewley thanks for the quick turnaround. Indeed our cmake use needs to be overhauled, the copying of dependencies is a side effect of having a two stage build process where the opensim-core build system deals with artifacts/files rather than targets that have other dependencies baked into their build. This though is beyond the scope of this PR. One hurdle is that the Moco stack is deep so the dependency propagation has to be baked into other large projects that we use (e.g ipopt and its dependencies etc.) but feel free to open an issue or let me know and I'll open one so we can address in due time.

Copy link
Member

@carmichaelong carmichaelong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed that while at some point refactoring our cmake files would be good, this PR is looking good as is. i left one comment about a test being removed all together (rather than keeping it with casadi) but i'm not too worried, just a double check

Reviewed 5 of 9 files at r1, 102 of 103 files at r3, 60 of 63 files at r4, 8 of 8 files at r5, 1 of 1 files at r6, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aymanhab)


OpenSim/Moco/Test/testMocoInterface.cpp line 1255 at r6 (raw file):

}

TEMPLATE_TEST_CASE("Guess time-stepping", "[tropter]",

does this test need to be kept with the casadi solver? my gut says that all these pieces are likely tested elsewhere, so i'd lean not, but just dou9ble checking

Copy link
Member

@nickbianco nickbianco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @carmichaelong and @adamkewley! I've added the time-stepping test back in.

Reviewable status: 175 of 176 files reviewed, 2 unresolved discussions (waiting on @aymanhab and @carmichaelong)


OpenSim/Moco/Test/testMocoInterface.cpp line 1255 at r6 (raw file):

Previously, carmichaelong wrote…

does this test need to be kept with the casadi solver? my gut says that all these pieces are likely tested elsewhere, so i'd lean not, but just dou9ble checking

This is a good test to include, I've added it back in.

Copy link
Member

@carmichaelong carmichaelong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 175 of 176 files reviewed, 1 unresolved discussion (waiting on @aymanhab)

Copy link
Member Author

@aymanhab aymanhab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 175 of 176 files reviewed, 1 unresolved discussion (waiting on @carmichaelong)

@nickbianco nickbianco merged commit 3eca9a9 into main Feb 27, 2025
11 of 13 checks passed
@nickbianco nickbianco deleted the remove_tropter_tests branch February 27, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants