Skip to content

Commit c67a11f

Browse files
committed
Disable pmap test on Travis
1 parent 8bcd94f commit c67a11f

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

test/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
1717
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1818
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1919
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
20-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2120
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
2221
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2322
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"

test/serialization.jl

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,43 @@
1717
@test mean(samples_m) 0 atol=0.1
1818
end
1919

20-
@testset "pmap" begin
21-
# Add worker processes.
22-
addprocs()
23-
@info "serialization test: using $(nworkers()) processes"
24-
25-
# Load packages on all processes.
26-
@everywhere begin
27-
using Pkg
28-
Pkg.activate(@__DIR__)
29-
Pkg.instantiate()
30-
using DynamicPPL
31-
using Distributions
32-
end
33-
34-
# Define model on all proceses.
35-
@everywhere @model function model()
36-
m ~ Normal(0, 1)
37-
end
38-
39-
# Generate `Model` objects on all processes.
40-
models = pmap(_ -> model(), 1:100)
41-
@test models isa Vector{<:Model}
42-
@test length(models) == 100
43-
44-
# Sample from model on all processes.
45-
n = 1_000
46-
samples1 = pmap(_ -> model()(), 1:n)
47-
m = model()
48-
samples2 = pmap(_ -> m(), 1:n)
49-
50-
for samples in (samples1, samples2)
51-
@test samples isa Vector{Float64}
52-
@test length(samples) == n
53-
@test mean(samples) 0 atol=0.1
54-
@test std(samples) 1 atol=0.1
20+
# Does not work reliably on Travis
21+
if haskey(ENV, "TRAVIS")
22+
@info "Skip `pmap` serialization test"
23+
else
24+
@testset "pmap" begin
25+
# Add worker processes.
26+
addprocs()
27+
@info "serialization test: using $(nworkers()) processes"
28+
29+
# Load packages on all processes.
30+
@everywhere begin
31+
using DynamicPPL
32+
using Distributions
33+
end
34+
35+
# Define model on all proceses.
36+
@everywhere @model function model()
37+
m ~ Normal(0, 1)
38+
end
39+
40+
# Generate `Model` objects on all processes.
41+
models = pmap(_ -> model(), 1:100)
42+
@test models isa Vector{<:Model}
43+
@test length(models) == 100
44+
45+
# Sample from model on all processes.
46+
n = 1_000
47+
samples1 = pmap(_ -> model()(), 1:n)
48+
m = model()
49+
samples2 = pmap(_ -> m(), 1:n)
50+
51+
for samples in (samples1, samples2)
52+
@test samples isa Vector{Float64}
53+
@test length(samples) == n
54+
@test mean(samples) 0 atol=0.1
55+
@test std(samples) 1 atol=0.1
56+
end
5557
end
5658
end
5759
end

0 commit comments

Comments
 (0)