diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml new file mode 100644 index 0000000000..6185015c44 --- /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-suggestions-on-pr.yml@v1" 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" diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml new file mode 100644 index 0000000000..6598488122 --- /dev/null +++ b/.github/workflows/Tests.yml @@ -0,0 +1,37 @@ +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: + tests: + name: "Tests" + 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 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 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 diff --git a/test/optimizationsystem.jl b/test/optimizationsystem.jl index 598f9c3f27..8bd39609e1 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 @@ -298,11 +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) - @test_throws ArgumentError 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, + @test_throws ErrorException OptimizationProblem(sys, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0], ucons = [0.0]) 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 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))