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

using AMGX errors on non-supported machines -- is there a good way to conditionally use AMGX? #22

Closed
navidcy opened this issue Oct 28, 2022 · 2 comments · Fixed by #24
Closed

Comments

@navidcy
Copy link
Contributor

navidcy commented Oct 28, 2022

So on a machine that can't support AMGX calling using AMGX gives an error. But it only gives that error the first time it's called! (See code below.)

Because using AMGX only errors the first time, an approach like

const hasamgx =
    try
        using AMGX
        true
    catch
        false
    end

won't work.

It would be good if using AMGX would always work. Otherwise developers need to figure out ways to load AMGX conditionally based on the machine. Any suggestions on how to do that? Or what's the best way to conditionally load AMGX? Is there, for example, a way to check whether libamgxsh exists or can be installed on the machine?

cc @glwagner, @elise-palethorpe

(base) navid:~/ (main) $ julia --project
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.2 (2022-09-29)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |

julia> using AMGX
ERROR: InitError: UndefVarError: libamgxsh not defined
Stacktrace:
 [1] getproperty
   @ ./Base.jl:31 [inlined]
 [2] __init__()
   @ AMGX ~/.julia/packages/AMGX/GFHHN/src/AMGX.jl:30
 [3] _include_from_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any})
   @ Base ./loading.jl:831
 [4] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64)
   @ Base ./loading.jl:1039
 [5] _require(pkg::Base.PkgId)
   @ Base ./loading.jl:1315
 [6] _require_prelocked(uuidkey::Base.PkgId)
   @ Base ./loading.jl:1200
 [7] macro expansion
   @ ./loading.jl:1180 [inlined]
 [8] macro expansion
   @ ./lock.jl:223 [inlined]
 [9] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1144
during initialization of module AMGX

julia> using AMGX

julia> a=1
1
@KristofferC
Copy link
Collaborator

We could only run the __init__ stuff if AMGX.AMGX_jll.is_available() returns true.

@navidcy
Copy link
Contributor Author

navidcy commented Oct 29, 2022

You mean in the __init__ of the AMGX package?

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 a pull request may close this issue.

2 participants