From 271dfba676931850ccb34a43b281c44560749394 Mon Sep 17 00:00:00 2001 From: Maximilian Ernst Date: Sun, 17 Mar 2024 16:41:55 +0100 Subject: [PATCH 1/6] add environment variable to CI to see if we are on CI --- .github/workflows/CI.yml | 1 + .github/workflows/CI_ecosystem.yml | 1 + .github/workflows/CI_extended.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 709a0125b..2df5f8c66 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -9,6 +9,7 @@ jobs: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} env: + JULIA_ON_CI: true JULIA_NUM_THREADS: 8 JULIA_EXTENDED_TESTS: false strategy: diff --git a/.github/workflows/CI_ecosystem.yml b/.github/workflows/CI_ecosystem.yml index 7d13369f8..897677440 100644 --- a/.github/workflows/CI_ecosystem.yml +++ b/.github/workflows/CI_ecosystem.yml @@ -12,6 +12,7 @@ jobs: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} env: + JULIA_ON_CI: true JULIA_NUM_THREADS: 8 JULIA_EXTENDED_TESTS: true strategy: diff --git a/.github/workflows/CI_extended.yml b/.github/workflows/CI_extended.yml index dd2e5816c..e793bdeb3 100644 --- a/.github/workflows/CI_extended.yml +++ b/.github/workflows/CI_extended.yml @@ -12,6 +12,7 @@ jobs: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} env: + JULIA_ON_CI: true JULIA_NUM_THREADS: 8 JULIA_EXTENDED_TESTS: true strategy: From 989ebf6c32c5cb0b3c477f8127c7ba2d0334bc43 Mon Sep 17 00:00:00 2001 From: Maximilian Ernst Date: Sun, 17 Mar 2024 16:45:33 +0100 Subject: [PATCH 2/6] switch to xtol instead of ftol for constrained NLopt test --- test/examples/political_democracy/constraints.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/examples/political_democracy/constraints.jl b/test/examples/political_democracy/constraints.jl index a9bc7aa1a..fd9275639 100644 --- a/test/examples/political_democracy/constraints.jl +++ b/test/examples/political_democracy/constraints.jl @@ -24,7 +24,7 @@ constrained_optimizer = SemOptimizerNLopt(; algorithm = :AUGLAG, local_algorithm = :LD_LBFGS, local_options = Dict( - :ftol_rel => 1e-6 + :xtol_rel => 1e-5 ), # equality_constraints = NLoptConstraint(;f = eq_constraint, tol = 1e-14), inequality_constraints = NLoptConstraint(;f = ineq_constraint, tol = 0.0), From 671c7229fdbb58023811fa8030c3270a1f48da84 Mon Sep 17 00:00:00 2001 From: Maximilian Ernst Date: Sun, 17 Mar 2024 16:45:49 +0100 Subject: [PATCH 3/6] fix local testing --- test/examples/political_democracy/political_democracy.jl | 6 +++--- test/runtests.jl | 2 +- test/unit_tests/multithreading.jl | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/examples/political_democracy/political_democracy.jl b/test/examples/political_democracy/political_democracy.jl index 29b29e3d4..ed70bdb3d 100644 --- a/test/examples/political_democracy/political_democracy.jl +++ b/test/examples/political_democracy/political_democracy.jl @@ -97,7 +97,7 @@ semoptimizer = SemOptimizerOptim semoptimizer = SemOptimizerNLopt @testset "RAMMatrices | constructor | NLopt" begin include("constructor.jl") end -if ENV["JULIA_EXTENDED_TESTS"] == "true" +if !haskey(ENV, "JULIA_EXTENDED_TESTS") || ENV["JULIA_EXTENDED_TESTS"] == "true" semoptimizer = SemOptimizerOptim @testset "RAMMatrices | parts | Optim" begin include("by_parts.jl") end semoptimizer = SemOptimizerNLopt @@ -121,7 +121,7 @@ semoptimizer = SemOptimizerOptim semoptimizer = SemOptimizerNLopt @testset "RAMMatrices → ParameterTable | constructor | NLopt" begin include("constructor.jl") end -if ENV["JULIA_EXTENDED_TESTS"] == "true" +if !haskey(ENV, "JULIA_EXTENDED_TESTS") || ENV["JULIA_EXTENDED_TESTS"] == "true" semoptimizer = SemOptimizerOptim @testset "RAMMatrices → ParameterTable | parts | Optim" begin include("by_parts.jl") end semoptimizer = SemOptimizerNLopt @@ -205,7 +205,7 @@ semoptimizer = SemOptimizerOptim semoptimizer = SemOptimizerNLopt @testset "Graph → ParameterTable | constructor | NLopt" begin include("constructor.jl") end -if ENV["JULIA_EXTENDED_TESTS"] == "true" +if !haskey(ENV, "JULIA_EXTENDED_TESTS") || ENV["JULIA_EXTENDED_TESTS"] == "true" semoptimizer = SemOptimizerOptim @testset "Graph → ParameterTable | parts | Optim" begin include("by_parts.jl") end semoptimizer = SemOptimizerNLopt diff --git a/test/runtests.jl b/test/runtests.jl index 6fdda7a89..0d401ed30 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,6 @@ using Test, SafeTestsets @time @safetestset "Unit Tests" begin include("unit_tests/unit_tests.jl") end @time @safetestset "Example Models" begin include("examples/examples.jl") end -if ENV["JULIA_EXTENDED_TESTS"] == "true" +if !haskey(ENV, "JULIA_EXTENDED_TESTS") || ENV["JULIA_EXTENDED_TESTS"] == "true" end \ No newline at end of file diff --git a/test/unit_tests/multithreading.jl b/test/unit_tests/multithreading.jl index 71da0bf2c..ba8770f19 100644 --- a/test/unit_tests/multithreading.jl +++ b/test/unit_tests/multithreading.jl @@ -1,5 +1,7 @@ using Test -@testset "multithreading_enabled" begin - @test Threads.nthreads() == 8 +if haskey(ENV, "JULIA_ON_CI") + @testset "multithreading_enabled" begin + @test Threads.nthreads() == 8 + end end \ No newline at end of file From 2c901495727a15b8d0d25a23c7e022621dc21a4f Mon Sep 17 00:00:00 2001 From: Maximilian Ernst Date: Sun, 17 Mar 2024 17:08:47 +0100 Subject: [PATCH 4/6] higher xtol for testing on macos --- test/examples/political_democracy/constraints.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/examples/political_democracy/constraints.jl b/test/examples/political_democracy/constraints.jl index fd9275639..4c0b3a336 100644 --- a/test/examples/political_democracy/constraints.jl +++ b/test/examples/political_democracy/constraints.jl @@ -24,7 +24,7 @@ constrained_optimizer = SemOptimizerNLopt(; algorithm = :AUGLAG, local_algorithm = :LD_LBFGS, local_options = Dict( - :xtol_rel => 1e-5 + :xtol_rel => 1e-4 ), # equality_constraints = NLoptConstraint(;f = eq_constraint, tol = 1e-14), inequality_constraints = NLoptConstraint(;f = ineq_constraint, tol = 0.0), From f0fe8273413a106af69f11da158a04f22a7b4a2e Mon Sep 17 00:00:00 2001 From: Maximilian Ernst Date: Sun, 17 Mar 2024 21:30:12 +0100 Subject: [PATCH 5/6] add tolerance for inequality constraint and set global instead of local xtol --- test/examples/political_democracy/constraints.jl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/examples/political_democracy/constraints.jl b/test/examples/political_democracy/constraints.jl index 4c0b3a336..b6a9477d0 100644 --- a/test/examples/political_democracy/constraints.jl +++ b/test/examples/political_democracy/constraints.jl @@ -23,11 +23,9 @@ end constrained_optimizer = SemOptimizerNLopt(; algorithm = :AUGLAG, local_algorithm = :LD_LBFGS, - local_options = Dict( - :xtol_rel => 1e-4 - ), + options = Dict(:xtol_rel => 1e-4), # equality_constraints = NLoptConstraint(;f = eq_constraint, tol = 1e-14), - inequality_constraints = NLoptConstraint(;f = ineq_constraint, tol = 0.0), + inequality_constraints = NLoptConstraint(;f = ineq_constraint, tol = 1e-8), ) model_ml_constrained = Sem( @@ -59,7 +57,7 @@ end @testset "ml_solution_constrained" begin solution_constrained = sem_fit(model_ml_constrained) - @test solution_constrained.solution[31]*solution_constrained.solution[30] >= 0.6 + @test solution_constrained.solution[31]*solution_constrained.solution[30] >= (0.6-1e-8) @test all(abs.(solution_constrained.solution) .< 10) @test solution_constrained.optimization_result.result[3] == :FTOL_REACHED skip=true @test abs(solution_constrained.minimum - 21.21) < 0.01 From 6544ee9f5106de9e5fc29ffb85419abbb81a0fbc Mon Sep 17 00:00:00 2001 From: Maximilian Ernst Date: Sun, 17 Mar 2024 21:45:11 +0100 Subject: [PATCH 6/6] stop testing on 1.9 --- .github/workflows/CI_ecosystem.yml | 1 - .github/workflows/CI_extended.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/CI_ecosystem.yml b/.github/workflows/CI_ecosystem.yml index 897677440..6cb852175 100644 --- a/.github/workflows/CI_ecosystem.yml +++ b/.github/workflows/CI_ecosystem.yml @@ -20,7 +20,6 @@ jobs: matrix: version: - '1' - - '1.9' os: - ubuntu-latest - macos-latest diff --git a/.github/workflows/CI_extended.yml b/.github/workflows/CI_extended.yml index e793bdeb3..308d4d09c 100644 --- a/.github/workflows/CI_extended.yml +++ b/.github/workflows/CI_extended.yml @@ -20,7 +20,6 @@ jobs: matrix: version: - '1' - - '1.9' os: - ubuntu-latest - macos-latest