GalacticOptim: Locally running runtests.jl fails

Hello all,
I want to add constraint support to the FiniteDiff-backend of the GalacticOptim.jl package. However, after creating a local repository of the package, I can’t get runtests.jl to work.

All tests using the Ipopt solver fail with the message:

Rosenbrock: Error During Test at C:\Users\Stefan Mathis\.julia\packages\SafeTestsets\A83XK\src\SafeTestsets.jl:25
  Got exception outside of a @test
  LoadError: The number of maxiters has to be a non-negative and non-zero number.

Uncommenting all Ipopt tests, the following NLopt test fails as well:

sol = solve(prob, GalacticOptim.MOI.OptimizerWithAttributes(NLopt.Optimizer, "algorithm" => :LN_BOBYQA))
@test 10*sol.minimum < l1

leads to

Rosenbrock: Error During Test at C:\Users\Stefan Mathis\.julia\packages\SafeTestsets\A83XK\src\SafeTestsets.jl:25
  Got exception outside of a @test
  LoadError: UndefVarError: MOI not defined

I therefore think I am doing something wrong trying to run the tests locally. I am using Julia 1.6 on Windows 10.

Any help would be very much appreciated. Thank you!

Let’s see if you’re crazy:

Certainly seems a bit like it :smiley: Regarding the Ipopt problem, I followed the stacktrace and found that it comes down to the the __solve method in src/solve/flux.jl:

function __solve(prob::OptimizationProblem, opt, data = DEFAULT_DATA;
                 maxiters::Number = 0, cb = (args...) -> (false),
                 progress = false, save_best = true, kwargs...)
                 
    if data != DEFAULT_DATA
      maxiters = length(data)
    else
      if maxiters <= 0.0
        error("The number of maxiters has to be a non-negative and non-zero number.")
      end
      data = take(data, maxiters)
    end

Corresponding error:

Rosenbrock: Error During Test at C:\Users\Stefan Mathis\.julia\packages\SafeTestsets\A83XK\src\SafeTestsets.jl:25
  Got exception outside of a @test
  LoadError: The number of maxiters has to be a non-negative and non-zero number.
  Stacktrace:
    [1] error(s::String)
      @ Base .\error.jl:33
    [2] __solve(prob::SciMLBase.OptimizationProblem{true, SciMLBase.OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(Main.##297.rosenbrock), Nothing, Nothing, Nothing, 
Main.##297.var"#1#2", Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Nothing, Vector{Float64}, Vector{Float64}, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, opt::Type, data::Base.Iterators.Cycle{Tuple{GalacticOptim.NullData}}; maxiters::Int64, cb::Function, progress::Bool, save_best::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
      @ GalacticOptim C:\Users\Stefan Mathis\.julia\dev\GalacticOptim\src\solve\flux.jl:25
    [3] __solve (repeats 2 times)
      @ C:\Users\Stefan Mathis\.julia\dev\GalacticOptim\src\solve\flux.jl:18 [inlined]
    [4] #solve#474
      @ C:\Users\Stefan Mathis\.julia\packages\SciMLBase\oTP8b\src\solve.jl:3 [inlined]
    [5] solve(::SciMLBase.OptimizationProblem{true, SciMLBase.OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(Main.##297.rosenbrock), Nothing, Nothing, Nothing, Main.##297.var"#1#2", Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Nothing, Vector{Float64}, Vector{Float64}, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::Type)
      @ SciMLBase C:\Users\Stefan Mathis\.julia\packages\SciMLBase\oTP8b\src\solve.jl:3
    [6] top-level scope
      @ C:\Users\Stefan Mathis\.julia\dev\GalacticOptim\test\rosenbrock.jl:56

Examining the call signature of the __solve method, it seems obvious that this errors when called with sol = solve(prob, Ipopt.Optimizer) in rosenbrock.jl, since neither data nor maxiters is provided. Therefore I don’t understand why your test run passed. What am I missing?

Is there anything random or stochastic in the test?

I don’t think so. I didn’t change anything compared to the master branch - just trying to get the tests to run before doing any editing. As written above, I do understand why the error occurs, but I don’t understand, why the tests you kindly performed didn’t fail. As far as I can tell, the solve(prob, Ipopt.Optimizer) call doesn’t provide the necessary information for the __solve function. So the interesting question is: How did the __solve function get a value for maxiters during your test run?

Are your local package versions the same as what is gotten on CI?

I downloaded the repo yesterday in the way you showed in your Youtube package development video. So I would assume so. However, this assumption may be wrong. How can I check the package versions in CI so I can compare them to my local versions?

============================================================================

UPDATE: You were correct, some packages were outdated indeed. I assumed that they would be updated when instantiating the package, but apparently I was wrong about that. Now the tests are running just fine. Thank you very much for checking!