From 82349349d78f6d7bfbaa777167426b45edddbcc2 Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam Date: Mon, 29 Apr 2024 19:20:56 +0530 Subject: [PATCH 01/12] ci: update invalidations workflow to use centralised reusable workflow --- .github/workflows/Invalidations.yml | 35 +++++------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/.github/workflows/Invalidations.yml b/.github/workflows/Invalidations.yml index d8f9dbe014..1e5662eb28 100644 --- a/.github/workflows/Invalidations.yml +++ b/.github/workflows/Invalidations.yml @@ -1,9 +1,9 @@ -name: Invalidations +name: "Invalidations" on: pull_request: paths-ignore: - - 'docs/**' + - 'docs/**' concurrency: # Skip intermediate builds: always. @@ -12,31 +12,6 @@ concurrency: cancel-in-progress: true jobs: - evaluate: - # Only run on PRs to the default branch. - # In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch - if: github.base_ref == github.event.repository.default_branch - runs-on: ubuntu-latest - steps: - - uses: julia-actions/setup-julia@v1 - with: - version: '1' - - uses: actions/checkout@v4 - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-invalidations@v1 - id: invs_pr - - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.repository.default_branch }} - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-invalidations@v1 - id: invs_default - - - name: Report invalidation counts - run: | - echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY - echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY - - name: Check if the PR does increase number of invalidations - if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total - run: exit 1 + evaluate-invalidations: + name: "Evaluate Invalidations" + uses: "SciML/.github/.github/workflows/invalidations.yml@v1" From 4b9044a50690695c1d49cb5a5e840b2cee1c4f5c Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam Date: Thu, 2 May 2024 21:03:12 +0530 Subject: [PATCH 02/12] ci: update tests workflow to use centralised reusable workflow --- .github/workflows/Tests.yml | 42 +++++++++++++++++ .github/workflows/ci.yml | 91 ------------------------------------- 2 files changed, 42 insertions(+), 91 deletions(-) create mode 100644 .github/workflows/Tests.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml new file mode 100644 index 0000000000..573e7becd8 --- /dev/null +++ b/.github/workflows/Tests.yml @@ -0,0 +1,42 @@ +name: "Tests" + +on: + pull_request: + branches: + - master + - 'release-' + paths-ignore: + - 'docs/**' + push: + branches: + - master + paths-ignore: + - 'docs/**' + +concurrency: + # Skip intermediate builds: always, but for the master branch. + # Cancel intermediate builds: always, but for the master branch. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + +jobs: + format-check: + name: "Format Check" + uses: "SciML/.github/.github/workflows/format-check.yml@v1" + + tests: + name: "Tests" + needs: format-check + strategy: + fail-fast: false + matrix: + group: + - InterfaceI + - InterfaceII + - Extensions + - Downstream + - RegressionI + uses: "SciML/.github/.github/workflows/tests.yml@v1" + with: + group: "${{ matrix.group }}" + secrets: "inherit" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 6a5b303404..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: CI -on: - pull_request: - branches: - - master - - 'release-' - paths-ignore: - - 'docs/**' - push: - branches: - - master - paths-ignore: - - 'docs/**' - -concurrency: - # Skip intermediate builds: always, but for the master branch. - # Cancel intermediate builds: always, but for the master branch. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} - -jobs: - formatter: - runs-on: ${{ matrix.os }} - strategy: - matrix: - julia-version: [1] - julia-arch: [x86] - os: [ubuntu-latest] - steps: - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.julia-version }} - - - uses: actions/checkout@v4 - - name: Install JuliaFormatter and format - # This will use the latest version by default but you can set the version like so: - # - # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))' - run: | - julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.50"))' - julia -e 'using JuliaFormatter; format(".", verbose=true)' - - name: Format check - run: | - julia -e ' - out = Cmd(`git diff`) |> read |> String - if out == "" - exit(0) - else - @error "Some files have not been formatted !!!" - write(stdout, out) - exit(1) - end' - test: - needs: formatter - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - group: - - InterfaceI - - InterfaceII - - Extensions - - Downstream - - RegressionI - version: - - '1' - steps: - - uses: actions/checkout@v4 - - uses: julia-actions/setup-julia@v1 - with: - version: ${{ matrix.version }} - - uses: actions/cache@v4 - env: - cache-name: cache-artifacts - with: - path: ~/.julia/artifacts - key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} - restore-keys: | - ${{ runner.os }}-test-${{ env.cache-name }}- - ${{ runner.os }}-test- - ${{ runner.os }}- - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-runtest@v1 - env: - GROUP: ${{ matrix.group }} - - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v4 - with: - file: lcov.info - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true From 04f78f396c745dd051891f4f61516ebcdadc6e1b Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam Date: Fri, 3 May 2024 17:44:15 +0530 Subject: [PATCH 03/12] ci: update format check workflow to use centralised reusable workflow Additionally, move the format check workflow to a separate job, following convention. --- .github/workflows/FormatCheck.yml | 13 +++++++++++++ .github/workflows/Tests.yml | 5 ----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/FormatCheck.yml diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml new file mode 100644 index 0000000000..c240796cc0 --- /dev/null +++ b/.github/workflows/FormatCheck.yml @@ -0,0 +1,13 @@ +name: "Format Check" + +on: + push: + branches: + - 'master' + tags: '*' + pull_request: + +jobs: + format-check: + name: "Format Check" + uses: "SciML/.github/.github/workflows/format-check.yml@v1" diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 573e7becd8..6598488122 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -20,13 +20,8 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} jobs: - format-check: - name: "Format Check" - uses: "SciML/.github/.github/workflows/format-check.yml@v1" - tests: name: "Tests" - needs: format-check strategy: fail-fast: false matrix: From be6cbb1641abb2e6e72e3cd3dd63e5400a172a59 Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam Date: Mon, 29 Jul 2024 20:37:33 +0200 Subject: [PATCH 04/12] ci(format-check): automatically comment formatting suggestions on PRs --- .github/workflows/FormatCheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index c240796cc0..6185015c44 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -10,4 +10,4 @@ on: jobs: format-check: name: "Format Check" - uses: "SciML/.github/.github/workflows/format-check.yml@v1" + uses: "SciML/.github/.github/workflows/format-suggestions-on-pr.yml@v1" From a5bc3b03b18f5cd624f523f2437aa20e11452328 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 Jul 2024 05:26:12 -0400 Subject: [PATCH 05/12] Update optimizationsystem.jl --- test/optimizationsystem.jl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/optimizationsystem.jl b/test/optimizationsystem.jl index 598f9c3f27..72e3e4906d 100644 --- a/test/optimizationsystem.jl +++ b/test/optimizationsystem.jl @@ -50,7 +50,7 @@ using ModelingToolkit: get_metadata cons_h = true) @test prob.f.sys === combinedsys sol = solve(prob, Ipopt.Optimizer(); print_level = 0) - @test sol.minimum < -1e5 + @test sol.objective < -1e5 end @testset "inequality constraint" begin @@ -66,14 +66,14 @@ end grad = true, hess = true, cons_j = true, cons_h = true) @test prob.f.sys === sys sol = solve(prob, IPNewton()) - @test sol.minimum < 1.0 + @test sol.objective < 1.0 sol = solve(prob, Ipopt.Optimizer(); print_level = 0) - @test sol.minimum < 1.0 + @test sol.objective < 1.0 prob = OptimizationProblem(sys, [x => 0.0, y => 0.0], [a => 1.0, b => 1.0], grad = false, hess = false, cons_j = false, cons_h = false) sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe)) - @test_skip sol.minimum < 1.0 + @test_skip sol.objective < 1.0 end @testset "equality constraint" begin @@ -88,18 +88,18 @@ end prob = OptimizationProblem(sys, [x => 0.0, y => 0.0, z => 0.0], [a => 1.0, b => 1.0], grad = true, hess = true, cons_j = true, cons_h = true) sol = solve(prob, IPNewton()) - @test sol.minimum < 1.0 + @test sol.objective < 1.0 @test sol.u≈[0.808, -0.064] atol=1e-3 @test sol[x]^2 + sol[y]^2 ≈ 1.0 sol = solve(prob, Ipopt.Optimizer(); print_level = 0) - @test sol.minimum < 1.0 + @test sol.objective < 1.0 @test sol.u≈[0.808, -0.064] atol=1e-3 @test sol[x]^2 + sol[y]^2 ≈ 1.0 prob = OptimizationProblem(sys, [x => 0.0, y => 0.0, z => 0.0], [a => 1.0, b => 1.0], grad = false, hess = false, cons_j = false, cons_h = false) sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe)) - @test_skip sol.minimum < 1.0 + @test_skip sol.objective < 1.0 @test_skip sol.u≈[0.808, -0.064] atol=1e-3 @test_skip sol[x]^2 + sol[y]^2 ≈ 1.0 end @@ -108,7 +108,7 @@ end rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2 x0 = zeros(2) p = [1.0, 100.0] - f = OptimizationFunction(rosenbrock, Optimization.AutoModelingToolkit()) + f = OptimizationFunction(rosenbrock, Optimization.AutoSymbolics()) prob = OptimizationProblem(f, x0, p) sol = solve(prob, Newton()) @test sol.u ≈ [1.0, 1.0] @@ -215,15 +215,15 @@ end Ipopt.Optimizer(); print_level = 0)) #= - @test sol.minimum < -1e5 + @test sol.objective < -1e5 prob = OptimizationProblem(sys2, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0], grad = true, hess = true, cons_j = true, cons_h = true) @test prob.f.sys === sys2 sol = solve(prob, IPNewton()) - @test sol.minimum < 1.0 + @test sol.objective < 1.0 sol = solve(prob, Ipopt.Optimizer(); print_level = 0) - @test sol.minimum < 1.0 + @test sol.objective < 1.0 =# end From f99f3bc2b2ecc9bf6823cbd05418307ac4501658 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 Jul 2024 11:16:51 -0400 Subject: [PATCH 06/12] Update modelingtoolkitize.jl --- test/modelingtoolkitize.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/modelingtoolkitize.jl b/test/modelingtoolkitize.jl index ac32f874ed..1e3825bb11 100644 --- a/test/modelingtoolkitize.jl +++ b/test/modelingtoolkitize.jl @@ -59,13 +59,13 @@ sys = complete(modelingtoolkitize(prob)) # symbolicitize me captain! prob = OptimizationProblem(sys, x0, p, grad = true, hess = true) sol = solve(prob, NelderMead()) -@test sol.minimum < 1e-8 +@test sol.objective < 1e-8 sol = solve(prob, BFGS()) -@test sol.minimum < 1e-8 +@test sol.objective < 1e-8 sol = solve(prob, Newton()) -@test sol.minimum < 1e-8 +@test sol.objective < 1e-8 ## SIR System Regression Test From 95440bde818d6e4783cfcd3d7ac8d7e28ae45173 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 31 Jul 2024 05:55:31 -0400 Subject: [PATCH 07/12] Update hierarchical_initialization_eqs.jl --- test/hierarchical_initialization_eqs.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hierarchical_initialization_eqs.jl b/test/hierarchical_initialization_eqs.jl index 82dc3cb566..1e3109a66e 100644 --- a/test/hierarchical_initialization_eqs.jl +++ b/test/hierarchical_initialization_eqs.jl @@ -142,6 +142,6 @@ syslist = ModelingToolkit.get_systems(model) u0 = [] prob = ODEProblem(structural_simplify(model), u0, (0.0, 10.0)) sol = solve(prob, Rodas5P()) -@test length(sol[end]) == 2 +@test length(sol.u[end]) == 2 @test length(equations(prob.f.initializeprob.f.sys)) == 0 @test length(unknowns(prob.f.initializeprob.f.sys)) == 0 From 011cc353256538d9e884653c9cac80f87dd536f7 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 31 Jul 2024 11:03:47 -0400 Subject: [PATCH 08/12] Update sdesystem.jl --- test/sdesystem.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sdesystem.jl b/test/sdesystem.jl index d71848bf4b..70dff7d97a 100644 --- a/test/sdesystem.jl +++ b/test/sdesystem.jl @@ -693,7 +693,7 @@ let # test to make sure that scalar noise always receive the same kicks @mtkbuild de = System(eqs, t) prob = SDEProblem(de, [x => 0, y => 0], (0.0, 10.0), []) sol = solve(prob, SOSRI()) - @test sol[end][1] == sol[end][2] + @test sol.u[end][1] == sol.u[end][2] end let # test that diagonal noise is correctly handled From 2031ee988e03e1970a98fba0a6caef51b0c1ac67 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 31 Jul 2024 11:04:17 -0400 Subject: [PATCH 09/12] Update variable_parsing.jl --- test/variable_parsing.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/variable_parsing.jl b/test/variable_parsing.jl index 1930b3273d..1ea366d045 100644 --- a/test/variable_parsing.jl +++ b/test/variable_parsing.jl @@ -33,10 +33,6 @@ s1 = Num(Sym{Real}(:s)) @test ModelingToolkit.isparameter(s) @test ModelingToolkit.isparameter(σ) -@derivatives D' ~ t -D1 = Differential(t) -@test D1 == D - @test @macroexpand(@parameters x, y, z(t)) == @macroexpand(@parameters x y z(t)) @test @macroexpand(@variables x, y, z(t)) == @macroexpand(@variables x y z(t)) From 0c9bb99fdfa7b5a8f558b5bad18cf45d81f2d42d Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 31 Jul 2024 11:05:02 -0400 Subject: [PATCH 10/12] Update optimizationsystem.jl --- test/optimizationsystem.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/optimizationsystem.jl b/test/optimizationsystem.jl index 72e3e4906d..19cfd78bef 100644 --- a/test/optimizationsystem.jl +++ b/test/optimizationsystem.jl @@ -298,6 +298,10 @@ end loss = (a - x)^2 + b * (y - x^2)^2 @named sys = OptimizationSystem(loss, [x, y], [a, b], constraints = [x^2 + y^2 ≲ 0.0]) sys = complete(sys) + OptimizationProblem(sys, + [x => 0.0, y => 0.0], + [a => 1.0, b => 100.0], + lcons = [0.0]) @test_throws ArgumentError OptimizationProblem(sys, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0], From 6869e92bf9241889ff86178cd0670ec6cb899be7 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 31 Jul 2024 12:15:37 -0400 Subject: [PATCH 11/12] Update test/optimizationsystem.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- test/optimizationsystem.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/optimizationsystem.jl b/test/optimizationsystem.jl index 19cfd78bef..c1562f175e 100644 --- a/test/optimizationsystem.jl +++ b/test/optimizationsystem.jl @@ -298,7 +298,7 @@ end loss = (a - x)^2 + b * (y - x^2)^2 @named sys = OptimizationSystem(loss, [x, y], [a, b], constraints = [x^2 + y^2 ≲ 0.0]) sys = complete(sys) - OptimizationProblem(sys, + OptimizationProblem(sys, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0], lcons = [0.0]) From 623f986def3b7cbc5599e5a1725f2f2939a33514 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 31 Jul 2024 12:16:03 -0400 Subject: [PATCH 12/12] Update optimizationsystem.jl --- test/optimizationsystem.jl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/optimizationsystem.jl b/test/optimizationsystem.jl index c1562f175e..8bd39609e1 100644 --- a/test/optimizationsystem.jl +++ b/test/optimizationsystem.jl @@ -298,15 +298,11 @@ end loss = (a - x)^2 + b * (y - x^2)^2 @named sys = OptimizationSystem(loss, [x, y], [a, b], constraints = [x^2 + y^2 ≲ 0.0]) sys = complete(sys) - OptimizationProblem(sys, + @test_throws ErrorException OptimizationProblem(sys, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0], lcons = [0.0]) - @test_throws ArgumentError OptimizationProblem(sys, - [x => 0.0, y => 0.0], - [a => 1.0, b => 100.0], - lcons = [0.0]) - @test_throws ArgumentError OptimizationProblem(sys, + @test_throws ErrorException OptimizationProblem(sys, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0], ucons = [0.0])