Add utilities for management of downloadable assets#386
Merged
ebrahimebrahim merged 8 commits intoOct 9, 2025
Merged
Conversation
2 tasks
aea41d3 to
4630d14
Compare
sadhana-r
approved these changes
Oct 2, 2025
Contributor
sadhana-r
left a comment
There was a problem hiding this comment.
Tested this via OpenwaterHealth/SlicerOpenLIFU#479 and it worked as expected
This is work towards #377 which will add more things that need to use PathLike
This allows you to now call run_reconstruction with download_masking_model set to False. This will skip the download of the MODNet weights, instead requiring the user to somehow ensure the model weights are installed. They can be installed from file using the newly added openlifu.util.assets.install_modnet_from_file.
This is a way of importing kwave while skipping its automatic download of binaries. We need to do this in order to get the binary paths from kwave to support offline use, or delayed download after a prompt, etc. It's not pretty, but even if we upgrade to the latest k-wave it should still work. I will add a unit test that uses this to make sure we catch any issues while upgrading kwave.
To check if kwave binaries are present, one can now do this: ``` all(p.exists() for p,_ in get_kwave_paths()) ``` And then if they are not present then one can ``` download_and_install_kwave_assets() ``` if there is an internet connection, otherwise us `install_kwave_asset_from_file` on individual needed files. The names of the needed files are ``` [p.name for p,_ in get_kwave_paths()] ```
This is needed to prevent kwave from getting auto imported just by importing openlifu. Otherwise we can never jump ahead of kwave's auto-download of its binaries to offer alternative ways of getting the binaries within openlifu.
4630d14 to
a3c8f57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #377.
This adds some downloadable-asset-management utilities to a new module
openlifu.util.assets, exposing ways to install assets from local files rather than via internet. Below is an overview of how to use these utilities.One can now call
run_reconstructionwithdownload_masking_modelset toFalse. This will skip the download of the MODNet weights, instead requiring the user to somehow ensure the model weights are installed. They can be installed from file using the newly addedopenlifu.util.assets.install_modnet_from_file.There is now a way of importing kwave while skipping its automatic download of binaries:
kwave = openlifu.util.assets._import_kwave_inertly(). We need to do this in order to get the binary paths from kwave to support offline use, or delayed download after a prompt, etc. The way it's done is not pretty, but even if we upgrade to the latest k-wave as of writing this it should still work. There is a unit test that uses this to make sure we catch any issues while upgrading kwave.To check if kwave binaries are present, one can now do this:
And then if they are not present then one can
if there is an internet connection, otherwise use
install_kwave_asset_from_fileon individual needed files. The names of the needed files areFull disclosure: Many of the added unit tests were AI generated. They were all vetted by me.