-
Notifications
You must be signed in to change notification settings - Fork 48
Fix pip module tests #423
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
Fix pip module tests #423
Conversation
This removes automatic module loading of the heavy wave.io module and is meant to fix cross module loading of unnecessary submodules. One example: `import loads` when installed via pip install "mhkit[loads]" imports `wave.resource.frequency_moment`, which also imports the unnecessary wave.io module which has a dependency on requests. This fails if the user doesn't have `requests` installed, but that module is not necessary to run `frequency_moment`.
Loads module tests call wave/contours.py which requires `statsmodels`
`requests` is small, common python library. There are some modules that pull from multiple modules (loads calls wave) which require `requests`. This always includes requests for all modules.
Loads tests call wave.contours, which need scikit-learn
This fix is implemented in PR 421 and is related, but not in scope of this change
|
@akeeste, this is good to go after the test-optional-pip-depencencies tests pass. These failures are expected and are fixed in #422
It may make sense to merge the 3 open PR's into develop and then merge that into main, but I will leave that up to you. If you go this route, LMK if there are merge conflicts, and I can fix them in each PR individually. |
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.
@simmsa the previous install command is likely failing because it was using the version on pypi which is currently broken. Your change updates it to install the local github clone which contains the entire source. I think we should be using the git clone as you updated to since we do that everywhere else.
I went forward with changes into main. Let's stick there until we get all of our bugfixes in and then we'll fast forward develop
|
Also can you clarify the forced install of netcdf and hdf5 except for river, power, utils, loads? If those modules don't depend on netcdf and hdf5, which were causing issues that you solved in #422, then we can simplify their tests by treating them identically to the other tests right? |
@akeeste thanks for looking into this. Did the test-optional-pip-dependencies tests every fully pass before? The failures here https://github.com/MHKiT-Software/MHKiT-Python/actions/runs/18510669330 in this test https://github.com/MHKiT-Software/MHKiT-Python/actions/runs/18510669330/job/52750802829: Are what this attempts to fix. During those tests it looks like there are interdependencies, i.e., the loads module imports frequency_moment from the wave module, which imports all wave modules, which imports the wave.io module, which has dependencies not specified in the loads module deps in pyproject.toml, and specifically in the above case, requests. In the above error the critical detail is that frequency_moment is not in the wave.io module. This means that the wave module imports are "greedy". This was fine before we allowed module specific installs, but now this design choice in the wave module init.py and downstream init.py files import everything within the wave module and which cause undesired side effects with other modules. The changes here fix the above interdependency errors in two ways:
|
Agreed. I think that |
Because the module code uses pip to install it will have the same "limitations" as other pip installs and we need to perform the same steps to add the h5 and nc binaries and then rebuild against them. Each of the tests are "independent" pip installs so we need individually install the necessary dependencies. We exclude the modules where nc/h5 files are not used which you listed above. |
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.
Thanks for clarifying @simmsa. The only tests that are failing are tcl errors. These will rerun on commits to main anyways. Approved and merging!

Status: Ready
This fixes test failures related to module loading using
pip install "mhkit[<module>]"syntax.There are some modules that have interdependencies with other modules, i.e., loads module needs wave module code that are causing test failures.
The root cause of test failures is specific packages that are not specified in pyproject.toml for a specific module, but are called when the tests are run.
The fix is to add lazy loading for the
wave.iomodule and reconfigure the modules in pyproject.toml to capture the a more correct dependency list derived from running the tests.Also the command that runs these tests was changed from
pip install -e "mhkit[<module>]" .topip install -e ".[<module>]"because the tests fail with-e "mhkit"but succeed with-e ".". I suspect that this changes the way mhkit is installed, but I don't know what the specific differences are.