Skip to content

Commit

Permalink
Change AnalysisPipeline into "package"-like project (#229)
Browse files Browse the repository at this point in the history
* Change AnalysisPipeline into "package"-like project

* add exeflag to `addprocs`

* reformat
  • Loading branch information
SamuelBrand1 authored May 20, 2024
1 parent 8431622 commit 6151772
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 33 deletions.
4 changes: 3 additions & 1 deletion pipeline/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name = "Analysis pipeline"
name = "AnalysisPipeline"
uuid = "66314692-3678-4cbb-b3ac-6fcb54505317"
authors = ["Sam Abbott", "Sam Brand", "Zach Susswein"]

[deps]
Expand All @@ -16,6 +17,7 @@ JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
CSV = "0.10"
Expand Down
5 changes: 2 additions & 3 deletions pipeline/scripts/run_pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ using Dagger
# Define the backend resources to use for the pipeline
# in this case we are using distributed local workers with loaded modules
using Distributed
pids = addprocs()
pids = addprocs(; exeflags = ["--project=$(Base.active_project())"])

@everywhere include("../src/AnalysisPipeline.jl")
@everywhere using .AnalysisPipeline
@everywhere using AnalysisPipeline

# Create an instance of the pipeline behaviour
pipeline = RtwithoutRenewalPipeline()
Expand Down
5 changes: 2 additions & 3 deletions pipeline/scripts/run_priorpred_pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ using Dagger
# Define the backend resources to use for the pipeline
# in this case we are using distributed local workers with loaded modules
using Distributed
pids = addprocs()
pids = addprocs(; exeflags = ["--project=$(Base.active_project())"])

@everywhere include("../src/AnalysisPipeline.jl")
@everywhere using .AnalysisPipeline
@everywhere using AnalysisPipeline

# Create an instance of the pipeline behaviour
pipeline = RtwithoutRenewalPriorPipeline()
Expand Down
1 change: 0 additions & 1 deletion pipeline/src/constructors/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ include("make_truth_data_configs.jl")
include("make_inference_configs.jl")
include("make_Rt.jl")
include("make_tspan.jl")
include("make_inference_method.jl")
20 changes: 10 additions & 10 deletions pipeline/test/constructors/test_constructors.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@testset "make_gi_params: returns a dictionary with correct keys" begin
using .AnalysisPipeline
using AnalysisPipeline
pipeline = RtwithoutRenewalPipeline()
params = make_gi_params(pipeline)

Expand All @@ -9,30 +9,30 @@
end

@testset "make_inf_generating_processes" begin
using .AnalysisPipeline, EpiAware
using AnalysisPipeline, EpiAware
pipeline = RtwithoutRenewalPipeline()
igps = make_inf_generating_processes(pipeline)
@test igps == [DirectInfections, ExpGrowthRate, Renewal]
end

@testset "make_Rt: returns an array" begin
using .AnalysisPipeline
using AnalysisPipeline
pipeline = RtwithoutRenewalPipeline()

Rt = make_Rt(pipeline)
@test Rt isa Array
end

@testset "default_tspan: returns an Tuple{Integer, Integer}" begin
using .AnalysisPipeline
using AnalysisPipeline
pipeline = RtwithoutRenewalPipeline()

tspan = make_tspan(pipeline)
@test tspan isa Tuple{Integer, Integer}
end

@testset "make_latent_model_priors: generates a dict with correct keys and distributions" begin
using .AnalysisPipeline, Distributions
using AnalysisPipeline, Distributions
pipeline = RtwithoutRenewalPipeline()

priors_dict = make_latent_model_priors(pipeline)
Expand All @@ -47,7 +47,7 @@ end
end

@testset "make_epiaware_name_model_pairs: generates a vector of Pairs with correct keys and latent models" begin
using .AnalysisPipeline, EpiAware
using AnalysisPipeline, EpiAware
pipeline = RtwithoutRenewalPipeline()

namemodel_vect = make_epiaware_name_model_pairs(pipeline)
Expand All @@ -57,7 +57,7 @@ end
end

@testset "make_inference_method: constructor and defaults" begin
using .AnalysisPipeline, EpiAware, ADTypes, AbstractMCMC
using AnalysisPipeline, EpiAware, ADTypes, AbstractMCMC
pipeline = RtwithoutRenewalPipeline()

method = make_inference_method(pipeline)
Expand All @@ -74,7 +74,7 @@ end
end

@testset "make_inference_method: for prior predictive checking" begin
using .AnalysisPipeline, EpiAware, ADTypes, AbstractMCMC
using AnalysisPipeline, EpiAware, ADTypes, AbstractMCMC
pipeline = RtwithoutRenewalPriorPipeline()

method = make_inference_method(pipeline)
Expand All @@ -84,7 +84,7 @@ end
end

@testset "make_truth_data_configs" begin
using .AnalysisPipeline
using AnalysisPipeline
pipeline = RtwithoutRenewalPipeline()
@testset "make_truth_data_configs should return a dictionary" begin
config_dicts = make_truth_data_configs(pipeline)
Expand All @@ -99,7 +99,7 @@ end
end

@testset "default inference configurations" begin
using .AnalysisPipeline
using AnalysisPipeline
pipeline = RtwithoutRenewalPipeline()

inference_configs = make_inference_configs(pipeline)
Expand Down
2 changes: 1 addition & 1 deletion pipeline/test/infer/test_InferenceConfig.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Test the InferenceConfig struct constructor
@testset "InferenceConfig" begin
using Distributions, .AnalysisPipeline, EpiAware
using Distributions, AnalysisPipeline, EpiAware

struct TestLatentModel <: AbstractLatentModel
end
Expand Down
2 changes: 1 addition & 1 deletion pipeline/test/pipeline/test_pipelinetypes.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@testset "EpiAwarePipeline Tests" begin
using .AnalysisPipeline
using AnalysisPipeline
@testset "AbstractEpiAwarePipeline" begin
@test_throws MethodError AbstractEpiAwarePipeline()
end
Expand Down
7 changes: 2 additions & 5 deletions pipeline/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using DrWatson, Test
quickactivate(@__DIR__(), "Analysis pipeline")
quickactivate(@__DIR__(), "AnalysisPipeline")

# Load analysis module
include(srcdir("AnalysisPipeline.jl"));

#run tests
# Run tests
include("pipeline/test_pipelinetypes.jl");
include("constructors/test_constructors.jl");
include("simulate/test_TruthSimulationConfig.jl");
Expand Down
2 changes: 1 addition & 1 deletion pipeline/test/simulate/test_SimulationConfig.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Test the TruthSimulationConfig struct constructor
@testset "TruthSimulationConfig" begin
using Distributions, .AnalysisPipeline, EpiAware
using Distributions, AnalysisPipeline, EpiAware
gi = Gamma(2, 2)
config = TruthSimulationConfig(
truth_process = [0.5, 0.8, 1.2], gi_mean = 3.0, gi_std = 2.0)
Expand Down
4 changes: 2 additions & 2 deletions pipeline/test/simulate/test_TruthSimulationConfig.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@testset "simulate runs" begin
using Distributions, .AnalysisPipeline, EpiAware
using Distributions, AnalysisPipeline, EpiAware
# Define a mock TruthSimulationConfig object for testing
config = TruthSimulationConfig(
truth_process = fill(1.5, 10), gi_mean = 2.0, gi_std = 2.0)
Expand All @@ -19,7 +19,7 @@
end

@testset "generate_truthdata" begin
using .AnalysisPipeline
using AnalysisPipeline
pipeline = RtwithoutRenewalPipeline()
truth_data_config = Dict("gi_mean" => 0.5, "gi_std" => 0.1)
truthdata = generate_truthdata(truth_data_config, pipeline)
Expand Down
7 changes: 3 additions & 4 deletions pipeline/test/test_full_inference.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Test
@testset "run inference for random scenario with short toy data" begin
using DrWatson, EpiAware
quickactivate(@__DIR__(), "Analysis pipeline")
include(srcdir("AnalysisPipeline.jl"))
using DrWatson
quickactivate(@__DIR__(), "AnalysisPipeline")

using .AnalysisPipeline
using AnalysisPipeline
pipeline = RtwithoutRenewalPipeline()

tspan = (1, 28)
Expand Down
2 changes: 1 addition & 1 deletion pipeline/test/test_prior_predictive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Test
quickactivate(@__DIR__(), "Analysis pipeline")
include(srcdir("AnalysisPipeline.jl"))

using .AnalysisPipeline
using AnalysisPipeline
pipeline = RtwithoutRenewalPriorPipeline()

tspan = (1, 28)
Expand Down

0 comments on commit 6151772

Please sign in to comment.