Skip to content
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

[Preferences] Test ignores preferences that are not explicitly listed as test dependencies. #3389

Open
carstenbauer opened this issue Feb 23, 2023 · 8 comments

Comments

@carstenbauer
Copy link
Member

Came up over at MPI.jl here.

Currently, ] test ignores JULIA_LOAD_PATH. On our cluster, we use the latter to expand the default load path to an extra directory (via JULIA_LOAD_PATH=:/some/global/path) that contains a Project.toml that sets some global preferences (e.g. for MPI.jl). Consequently, the global preferences aren't respected within ] test.

I see two possible ways forward:

  1. Make ] test respect JULIA_LOAD_PATH. (Why doesn't it?)
  2. Propagate all preferences that are set along the load path to the test environment. (This is along the lines of Pkg.test() drops Preferences #2500 and Improve handling of preferences for sandboxes used in Pkg #2920 which didn't cover the case of global preferences, IIUC.)

(Tested with Julia 1.8.5)

@carstenbauer carstenbauer changed the title ] test ignores global preferences (because it ignores JULIA_LOAD_PATH) ] test doesn't get global preferences (because it ignores JULIA_LOAD_PATH) Feb 23, 2023
@fredrikekre fredrikekre transferred this issue from JuliaLang/julia Feb 23, 2023
@carstenbauer
Copy link
Member Author

carstenbauer commented Feb 23, 2023

Maybe I'm wrong with my point 2) above. MWE:

Minimal package with the following Project.toml and test/runtest.jl:

name = "mwe"
uuid = "4187ee2f-2d69-45e0-8479-75d21fecdd8d"
authors = ["Carsten Bauer <[email protected]>"]
version = "0.1.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

[extras]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "LinearAlgebra", "Preferences"]
@show LOAD_PATH
using Preferences, LinearAlgebra
@show Preferences.load_preference(LinearAlgebra, "testpref")

Now, an extra Project.toml in some global path (say /some/global/path) with the following content:

[extras]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[preferences.LinearAlgebra]
testpref = 1

Running JULIA_LOAD_PATH=:/some/global/path julia --project and then ] test I get

LOAD_PATH = ["@", "/var/folders/qk/nm34_hqn7_7g8fvxgpg24gm40000gn/T/jl_CemQ7p"]
Preferences.load_preference(LinearAlgebra, "testpref") = 1

So, despite the fact that /some/global/path isn't in LOAD_PATH, the preference seems to propagate fine!

(Why didn't it for MPIPreferences than?)

@vchuravy
Copy link
Member

vchuravy commented Feb 23, 2023

breadcrumbs #3061 and JuliaParallel/MPI.jl#561

cc: @staticfloat

@vchuravy
Copy link
Member

What happens if you add MPIPreferences to the test dependencies?

@carstenbauer
Copy link
Member Author

carstenbauer commented Feb 24, 2023

What happens if you add MPIPreferences to the test dependencies?

That works!

So I take it that only preferences of direct test dependencies are forwarded?

@vchuravy
Copy link
Member

vchuravy commented Feb 24, 2023

Hm still smells like a bug, we use Base.get_preferences to collect the Preferences to propagate, and while #3061 added load path, get_preferences might only collect preferences of direct dependencies.

But looking at https://github.com/JuliaLang/julia/blob/b5482c82d486aaa68939871eb1d1bc71bb421096/base/loading.jl#L2608 I don't see how or why that would happen/

@vchuravy vchuravy changed the title ] test doesn't get global preferences (because it ignores JULIA_LOAD_PATH) [Preferences] Test ignores preferences that are not explicitly listed as test dependencies. Feb 26, 2023
@vchuravy
Copy link
Member

@staticfloat

test_project_preferences = Base.get_preferences()
returns a dictonary of Name=>Prefs but no associated Name=>UUID mapping. We then copy over the preferences
open(tmp_preferences, "w") do io
to the test environment, but preference loading will ignore them since the tmp_project does not contain an appropriate Name=>UUID mapping.

simonbyrne added a commit to CliMA/Oceananigans.jl that referenced this issue Oct 10, 2023
navidcy pushed a commit to CliMA/Oceananigans.jl that referenced this issue Oct 11, 2023
* add buildkite

* precompile test env

* don't require gpus to be on 1 node

* print MPI versioninfo

* Add pref overrides to test deps

Work around JuliaLang/Pkg.jl#3389

* try overriding OpenMPI_jll

* use newer version of OpenMPI_jll

* try rearranging Init

* remove distributed tests on tartarus

---------

Co-authored-by: Simone Silvestri <[email protected]>
@JBlaschke
Copy link

In case people find this, to make CUDA pick up local configurations, you need to add:

CUDA_Runtime_jll = "76a88914-d11a-5bdc-97e0-2f5a05c973a2"

That shouldn't be necessary if the JULIA_LOAD_PATH was respected -- what causes this behavior in Pkg.test?

@carstenbauer
Copy link
Member Author

That shouldn't be necessary if the JULIA_LOAD_PATH was respected -- what causes this behavior in Pkg.test?

Related: JuliaPackaging/Preferences.jl#33

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

No branches or pull requests

3 participants