# GalacticOptim: Locally running runtests.jl fails

**URL:** <https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591>\
**Category:** Machine Learning\
**Created:** [July 13, 2021, 4:29pm UTC](https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591 "2021-07-13T16:29:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![StefanMathis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefanmathis/32/27106_2.png) [@StefanMathis](https://discourse.julialang.org/u/StefanMathis)\
**Post date:** [July 13, 2021, 4:29pm UTC](https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591/1 "2021-07-13T16:29:10Z")

</div>

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:

```julia
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:

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

```

leads to

```julia
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!

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 13, 2021, 5:58pm UTC](https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591/2 "2021-07-13T17:58:01Z")

</div>

Let’s see if you’re crazy:

> <https://github.com/SciML/Optimization.jl/pull/147>

---

<div class="post-metadata">

**Author:** ![StefanMathis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefanmathis/32/27106_2.png) [@StefanMathis](https://discourse.julialang.org/u/StefanMathis)\
**Post date:** [July 13, 2021, 6:36pm UTC](https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591/3 "2021-07-13T18:36:17Z")

</div>

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

```julia
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:

```julia
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?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 13, 2021, 9:18pm UTC](https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591/4 "2021-07-13T21:18:45Z")

</div>

Is there anything random or stochastic in the test?

---

<div class="post-metadata">

**Author:** ![StefanMathis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefanmathis/32/27106_2.png) [@StefanMathis](https://discourse.julialang.org/u/StefanMathis)\
**Post date:** [July 14, 2021, 5:30am UTC](https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591/5 "2021-07-14T05:30:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 14, 2021, 11:45am UTC](https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591/6 "2021-07-14T11:45:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![StefanMathis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefanmathis/32/27106_2.png) [@StefanMathis](https://discourse.julialang.org/u/StefanMathis)\
**Post date:** [July 14, 2021, 12:49pm UTC](https://discourse.julialang.org/t/galacticoptim-locally-running-runtests-jl-fails/64591/7 "2021-07-14T12:49:37Z")

</div>

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!
