-
Notifications
You must be signed in to change notification settings - Fork 143
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
Use Preferences for using custom hdf5 library #1061
Conversation
Honestly, I don't understand why the tests complain about |
Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
Please run the formatter. See the contrib folder for a utility. Also this is breaking so I think we will want to version bump to 0.17 unless we implement a fallback. I'm also wondering if we could include a migration utility. |
MPI.jl had performed a similar migration last year, from configuration via environment variables to using Preferences. Back then they solved this by adding a migration guide to the docs and included notes for HPC administrators on how to configure this on clusters with managed MPI/HDF5 installations. Maybe this can serve as a blueprint for this PR here as well? |
This should probably be mentioned in https://github.com/JuliaIO/HDF5.jl/blob/master/HISTORY.md, too, I guess? |
Yes, please document this as much as possible. If we do provide migration instructions, that should also be tested. |
I provided some migration instructions. |
This reads already very well! One suggestion from my side: Maybe you can give an example for admins of clusters what the Preferences file could look like and maybe explicitly mention that for backward compatibility it is recommended to both set the environment variables and use the Preferences file for the time being. But these are just suggestions, they are not critical IMHO. Other than that, this PR LGTM! |
I've also added an example of how the LocalPreferences.toml could look like and added a recommendation to also set the environment variable for backward compatibility. |
Great, thanks! |
For me, it's also failing on master with the same error using a local libhdf5 v1.10.6 on julia> versioninfo()
Julia Version 1.9.0
Commit 8e630552924 (2023-05-07 11:25 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
Threads: 1 on 8 virtual cores
Environment:
JULIA_HDF5_PATH = /usr/lib/x86_64-linux-gnu/hdf5/openmpi I'm rather confused why it's not failing in the other CI tests from other PRs. |
I think the problem is that We previously thought it was a buggy JLL, but it could just be all v1.10. I was able to replicate the error with a local build using libhdf5 1.10.7. I suggest we just disable the virtual dataset tests if using libhdf5 <1.12. |
That totally makes sense. Thanks, @simonbyrne! I disabled the virtual datasets tests for libhdf5 < 1.12. |
Loading MPI.jl before HDF5.jl is not required anymore with Preferences.jl, right? I changed the docs accordingly. |
Status of this PR is that HDF5.jl still uses Requires.jl to load the MPI code, doesn't it? If so, it's still necessary to first load MPI.jl as far as I know |
d05bb58
to
bd14d4f
Compare
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! Looks good to me. Let's keep fingers crossed that tests pass 🤞
Could we issue a warning if we detect that the environment variable |
Done in 8e98087. |
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.
The warning should be done during __init__
since the environment can change after precompilation occurs. Also, since we are encouraging people to set both the enviornment variable and Preferences.jl we should not warn if they are in fact using both.
I'm also wondering if we should just add a convenience method HDF5.API.set_libraries!
.
const HDF5_JL_UUID = UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f")
function set_libraries!(libhdf5 = nothing, libhdf5_hl = nothing; force = true)
if isnothing(libhdf5) && isnothing(libhdf5_hl)
delete_preferences!(HDF5_JL_UUID, "libhdf5")
delete_preferences!(HDF5_JL_UUID, "libhdf5_hl")
delete_preferences!("HDF5_jll", "libhdf5", "libhdf5_hl")
@info "The libraries from HDF5_jll will be used."
elseif isnothing(libhdf5) && isnothing(libhdf5_hl)
throw(ArgumentError("Specify either no positional arguments or both positional arguments."))
else
isfile(libhdf5) || throw(ArgumentError("$libhdf5 is not a file that exists.")
isfile(libhdf5_hl) || throw(ArgumentError("$libhdf5_hl is not a file that exists.")
set_preferences!(HDF5_JL_UUID, "libhdf5" => libhdf5; force)
set_preferences!(HDF5_JL_UUID, "libhdf5_hl" => libhdf5_hl; force)
# Also set the HDF5_jll override settings in case some other package tries to use HDF5_jll
set_preferences!(
"HDF5_jll",
"libhdf5_path" => libhdf5,
"libhdf5_jl_path" => libhdf5_jl
)
end
@info "Please restart Julia and reload HDF5.jl for the library changes to take effect"
end
See https://github.com/jheinen/GR.jl/blob/master/src/preferences.jl for further inspiration. Perhaps that is for another pull request.
test/configure_packages.jl
Outdated
import UUIDs, Preferences | ||
Preferences.set_preferences!( | ||
UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl | ||
"libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5.so"); |
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.
Could libhdf5.so also be in a lib
or lib64
subdirectory?
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.
Not as it is now. Primarily, I created this file for CI, where we know, where the binaries are located. Now, that we suggest the user to have a look at this file, it would probably be nice to also allow the binaries to be in joinpath(JULIA_HDF5_PATH, "lib")
or joinpath(JULIA_HDF5_PATH, "lib64")
.
I think we should also document configuring HDF5_jll as well in case some other package tries to load that. See https://docs.binarybuilder.org/stable/jll/#Overriding-specific-products |
If you would prefer, I would be fine merging this as is and implementing the above later. |
Co-authored-by: Simon Byrne <[email protected]> Co-authored-by: Mark Kittisopikul <[email protected]>
Co-authored-by: Mark Kittisopikul <[email protected]>
I addressed most of the suggestions. The remaining parts can be done in a separate PR. |
🥳 |
This switches to Preferences.jl for using a system-provided hdf5 library and replaces the additional build step.
Additionally, I allowed additional names of the library binaries as in my case, e.g., the binaries are located in/usr/lib/x86_64-linux-gnu/libhdf5_openmpi.so
and/usr/lib/x86_64-linux-gnu/libhdf5_openmpi_hl.so
.closes #1037
cc @ranocha, @sloede