Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test restructuring #2237

Merged
merged 30 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
15ffdc1
Remove unused test util function
mhauru May 23, 2024
91956d5
Refactoring ad and optiminterface tests to modules
mhauru May 23, 2024
58c6561
Add SelectiveTests.jl
mhauru May 28, 2024
3097f49
Rework tests CI GA
mhauru May 29, 2024
00bd2e0
Switch test CI on Mac back to x64
mhauru May 29, 2024
e40456d
Remove coverage from CI. Improve matrix.
mhauru May 29, 2024
b9c94be
Wrap all tests in modules.
mhauru May 29, 2024
797566e
Remove unused test utils
mhauru May 29, 2024
b2ef761
Remove GA workflows for DynamicHMC and Numerical
mhauru May 29, 2024
235256d
Rename TuringCI GA to Tests
mhauru May 29, 2024
185e14f
Fix test_args passing in CI
mhauru May 29, 2024
6ba68a5
Fix for CI test matrix
mhauru May 29, 2024
3c4bed4
Fixes to various test files
mhauru May 29, 2024
7d6fde5
Add container.jl to test suite
mhauru May 29, 2024
6964622
Fix spacing around * in test includes
mhauru May 31, 2024
4cdd6b2
Split ad.jl and abstractmcmc.jl tests to separate CI jobs
mhauru May 31, 2024
a16204b
Alphabetise imports in tests
mhauru May 31, 2024
2c38e17
In tests, use import X over using X: X
mhauru May 31, 2024
d4a728c
Add missing imports to abstractmcmc.jl tests
mhauru May 31, 2024
c624f81
Add some missing imports to tests
mhauru May 31, 2024
d370259
Merge ad_utils.jl to ad.jl in tests
mhauru May 31, 2024
0b80dbc
Merge testing_functions.jl into mh.jl in tests
mhauru May 31, 2024
2d7b101
Simplify test_utils
mhauru May 31, 2024
3ee5a2e
Add missing import to numerical_tests.jl
mhauru May 31, 2024
c6e8ecd
Merge remote-tracking branch 'origin/master' into mhauru/test-restruc…
mhauru Jun 3, 2024
6a015a3
Update Project.toml (#2244)
yebai Jun 3, 2024
de75f96
Set fail-fast: false for CI test matrix
mhauru Jun 3, 2024
5900ac9
Add a step to print matrix variables to tests Action
mhauru Jun 3, 2024
d2bfa5d
Fix typo in tests Action
mhauru Jun 3, 2024
b1ee983
ADTypes v0.2 compatibility for test restructuring (#2253)
mhauru Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions .github/workflows/DynamicHMC.yml

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/Numerical.yml

This file was deleted.

77 changes: 77 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Tests

on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}

strategy:
matrix:
test-args:
# Run some of the slower test files individually. The last one catches everything
# not included in the others.
- "mcmc/gibbs.jl"
- "mcmc/hmc.jl"
- "mcmc/Inference.jl"
- "experimental/gibbs.jl"
- "mcmc/ess.jl"
- "--skip mcmc/gibbs.jl mcmc/hmc.jl mcmc/Inference.jl experimental/gibbs.jl mcmc/ess.jl"
version:
- '1.7'
- '1'
os:
- ubuntu-latest
- windows-latest
- macOS-latest
arch:
- x64
- x86
num_threads:
- 1
- 2
exclude:
# With Windows and macOS, only run Julia 1.7, x64, 2 threads. We just want to see
# some combination work on OSes other than Ubuntu.
- os: windows-latest
version: '1'
- os: macOS-latest
version: '1'
- os: windows-latest
arch: x86
- os: macOS-latest
arch: x86
- os: windows-latest
num_threads: 1
- os: macOS-latest
num_threads: 1
# It's sufficient to test x86 with one version of Julia and one thread.
- version: '1'
arch: x86
- num_threads: 2
arch: x86

steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '${{ matrix.version }}'
arch: ${{ matrix.arch }}
- 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@latest
- name: Call Pkg.test
run: julia --color=yes --depwarn=yes --check-bounds=yes --threads=${{ matrix.num_threads }} --project=@. -e 'import Pkg; Pkg.test(; test_args=ARGS)' -- ${{ matrix.test-args }}
70 changes: 0 additions & 70 deletions .github/workflows/TuringCI.yml

This file was deleted.

26 changes: 24 additions & 2 deletions test/essential/ad.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
module AdTests

using LinearAlgebra
using Test: @testset, @test

using ForwardDiff
using ReverseDiff
using Distributions: logpdf
import LogDensityProblems
import LogDensityProblemsAD
using Zygote

using Turing
using DynamicPPL: getval, getlogp
using Turing: SampleFromPrior
willtebbutt marked this conversation as resolved.
Show resolved Hide resolved

include(pkgdir(Turing)*"/test/test_utils/models.jl")
include(pkgdir(Turing)*"/test/test_utils/ad_utils.jl")
mhauru marked this conversation as resolved.
Show resolved Hide resolved

@testset "ad.jl" begin
@turing_testset "adr" begin
@testset "adr" begin
ad_test_f = gdemo_default
vi = Turing.VarInfo(ad_test_f)
ad_test_f(vi, SampleFromPrior())
Expand Down Expand Up @@ -50,7 +69,8 @@
∇E2 = LogDensityProblems.logdensity_and_gradient(zygoteℓ, x)[2]
@test sort(∇E2) ≈ grad_FWAD atol = 1e-9
end
@turing_testset "general AD tests" begin

@testset "general AD tests" begin
# Tests gdemo gradient.
function logp1(x::Vector)
dist_s = InverseGamma(2, 3)
Expand Down Expand Up @@ -179,3 +199,5 @@
@test ℓ_grad == ℓ_grad_compiled
end
end

end
16 changes: 14 additions & 2 deletions test/essential/container.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
module ContainerTests

using Test: @test, @testset

using AdvancedPS: AdvancedPS
using Distributions: Normal, Bernoulli, Gamma, Beta
using DynamicPPL: @model, Sampler

using Turing

@testset "container.jl" begin
@model function test()
a ~ Normal(0, 1)
Expand All @@ -9,7 +19,7 @@
x
end

@turing_testset "constructor" begin
@testset "constructor" begin
vi = DynamicPPL.VarInfo()
sampler = Sampler(PG(10))
model = test()
Expand All @@ -29,7 +39,7 @@
@test DynamicPPL.get_num_produce(newtrace.model.f.varinfo) == 1
end

@turing_testset "fork" begin
@testset "fork" begin
@model function normal()
a ~ Normal(0, 1)
3 ~ Normal(a, 2)
Expand All @@ -48,3 +58,5 @@
@test AdvancedPS.advance!(trace) ≈ AdvancedPS.advance!(newtrace)
end
end

end
14 changes: 13 additions & 1 deletion test/experimental/gibbs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
using Test, Random, Turing, DynamicPPL
module ExperimentalGibbsTests

using Random
using Test

using DynamicPPL

using Turing

include(pkgdir(Turing)*"/test/test_utils/models.jl")
include(pkgdir(Turing)*"/test/test_utils/numerical_tests.jl")

function check_transition_varnames(
transition::Turing.Inference.Transition,
Expand Down Expand Up @@ -187,3 +197,5 @@ end
check_MoGtest_default_z_vector(chain, atol = 0.2)
end
end

end
14 changes: 14 additions & 0 deletions test/ext/Optimisation.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
module OptimisationTests

using Random: Random
using Test: @testset, @test

using Optimization
using OptimizationOptimJL: optimize, NelderMead, LBFGS, Fminbox, BFGS

using Turing

include(pkgdir(Turing)*"/test/test_utils/models.jl")

@testset "ext/Optimisation.jl" begin
@testset "gdemo" begin
@testset "MLE" begin
Expand Down Expand Up @@ -121,3 +133,5 @@
end
end
end

end
18 changes: 17 additions & 1 deletion test/ext/dynamichmc.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
module DynamicHMCTests

using Test: @testset, @test
using Random: Random

using Distributions: sample
using DynamicPPL: DynamicPPL
using DynamicPPL: Sampler
using DynamicHMC: DynamicHMC

using Turing

include(pkgdir(Turing)*"/test/test_utils/models.jl")
include(pkgdir(Turing)*"/test/test_utils/numerical_tests.jl")

@testset "TuringDynamicHMCExt" begin
import DynamicHMC
Random.seed!(100)

@test DynamicPPL.alg_str(Sampler(externalsampler(DynamicHMC.NUTS()))) == "DynamicNUTS"
Expand All @@ -8,3 +22,5 @@
chn = sample(gdemo_default, spl, 10_000)
check_gdemo(chn)
end

end
Loading