Skip to content

Commit

Permalink
Let runtests.jl handle testing
Browse files Browse the repository at this point in the history
* fix bug in main.yml (tests renamed to test)
* update RunSampling.jl to reference pcvct.jl
  • Loading branch information
drbergman committed Sep 5, 2024
1 parent 88402ee commit a3644d4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 35 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ jobs:
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- name: Set environment variable PHYSICELL_CPP
run: echo "PHYSICELL_CPP=${{ matrix.compiler }}" >> $GITHUB_ENV
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1 # not sure what this does yet...runs files marked as tests?
- name: Install julia dependencies
run: |
julia -e 'using Pkg; \
Pkg.add(["DataFrames", "CSV", "SQLite", "Random", "LightXML", "LazyGrids", "Dates", "Tables", "Distributions", "Statistics", "QuasiMonteCarlo", "Sobol", "MAT", "FFTW", "GlobalSensitivity"]); \
Pkg.update()'
echo "Julia packages added and updated"
- name: Set environment variable PHYSICELL_CPP
run: echo "PHYSICELL_CPP=${{ matrix.compiler }}" >> $GITHUB_ENV
- name: Run sampling
run: |
cd ./tests
julia -t 8 ./test-project/VCT/RunSampling.jl
echo "RunSampling.jl complete"
# - name: Install julia dependencies
# run: |
# julia -e 'using Pkg; \
# Pkg.add(["DataFrames", "CSV", "SQLite", "Random", "LightXML", "LazyGrids", "Dates", "Tables", "Distributions", "Statistics", "QuasiMonteCarlo", "Sobol", "MAT", "FFTW", "GlobalSensitivity"]); \
# Pkg.update()'
# echo "Julia packages added and updated"
# - name: Run sampling
# run: |
# cd ./test
# julia -t 8 ./test-project/VCT/RunSampling.jl
# echo "RunSampling.jl complete"
8 changes: 4 additions & 4 deletions src/VCTLoader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end

function getLabels(xml_doc::XMLDocument)
xml_path = ["cellular_information", "cell_populations", "cell_population", "custom", "simplified_data", "labels"]
labels_element = VCTModule.retrieveElement(xml_doc, xml_path; required=true)
labels_element = retrieveElement(xml_doc, xml_path; required=true)

labels = String[]
for label in child_elements(labels_element)
Expand All @@ -45,17 +45,17 @@ indexToFilename(index::Int) = "output$(lpad(index,8,"0"))"

function PhysiCellSnapshot(folder::String, index::Union{Int, Symbol}; labels::Vector{String}=String[])
filepath_base = "$(folder)/$(indexToFilename(index))"
xml_doc = VCTModule.openXML("$(filepath_base).xml")
xml_doc = openXML("$(filepath_base).xml")
mat_file = "$(filepath_base)_cells.mat"
time = VCTModule.getField(xml_doc, ["metadata","current_time"]) |> x->parse(Float64, x)
time = getField(xml_doc, ["metadata","current_time"]) |> x->parse(Float64, x)
if isempty(labels)
labels = getLabels(xml_doc)
end
cells = DataFrame(matread(mat_file)["cell"]', labels)
cells[!,:ID] = convert.(Int,cells[!,:ID])
cells[!,:dead] = convert.(Bool,cells[!,:dead])
cells[!,:cell_type] = convert.(Int,cells[!,:cell_type])
VCTModule.closeXML(xml_doc)
closeXML(xml_doc)
return PhysiCellSnapshot(folder, index, time, DataFrame(cells))
end

Expand Down
2 changes: 0 additions & 2 deletions src/pcvct.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module pcvct

include("VCTModule.jl")
# using .VCTModule
# export VCTModule

end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ using Test

@testset "pcvct.jl" begin
# Write your tests here.
@assert 2+2==4
include("./test-project/VCT/RunSampling.jl")
end
30 changes: 15 additions & 15 deletions test/test-project/VCT/RunSampling.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include("../../../src/VCTModule.jl") # include
using .VCTModule
using Test, pcvct

# include("../../../src/pcvct.jl") # include
# using .pcvct

path_to_physicell_folder = "./PhysiCell" # path to PhysiCell folder
path_to_data_folder = "./test-project/data" # path to data folder
Expand All @@ -22,7 +24,7 @@ config_variation_ids, rulesets_variation_ids = addVariations(GridVariation(), co

println("""
############################################
## DATABASE SUCCESSFULLY INITIALIZED! ##
## DATABASE SUCCESSFULLY UPDATED! ##
############################################
""")

Expand Down Expand Up @@ -63,8 +65,8 @@ println("""
############################################
""")

query = VCTModule.constructSelectQuery("simulations", "")
df = queryToDataFrame(query; is_row=true)
query = pcvct.constructSelectQuery("simulations", "")
df = pcvct.queryToDataFrame(query; is_row=true)

println("""
############################################
Expand All @@ -75,19 +77,17 @@ println("""
monad_min_length = 2

EV = ElementaryVariation[]
xml_path = [VCTModule.cyclePath("default"); "phase_durations"; "duration:index:0"]
xml_path = [pcvct.cyclePath("default"); "phase_durations"; "duration:index:0"]
push!(EV, ElementaryVariation(xml_path, [1.0, 2.0]))
xml_path = [VCTModule.cyclePath("default"); "phase_durations"; "duration:index:1"]
xml_path = [pcvct.cyclePath("default"); "phase_durations"; "duration:index:1"]
push!(EV, ElementaryVariation(xml_path, [3.0, 4.0]))
xml_path = [VCTModule.cyclePath("default"); "phase_durations"; "duration:index:2"]
xml_path = [pcvct.cyclePath("default"); "phase_durations"; "duration:index:2"]
push!(EV, ElementaryVariation(xml_path, [5.0, 6.0]))
xml_path = [VCTModule.cyclePath("default"); "phase_durations"; "duration:index:3"]
xml_path = [pcvct.cyclePath("default"); "phase_durations"; "duration:index:3"]
push!(EV, ElementaryVariation(xml_path, [7.0, 8.0]))

reference_config_variation_id = config_variation_id
reference_rulesets_variation_id = rulesets_variation_id

sampling = Sampling(monad_min_length, config_folder, rulesets_collection_folder, ic_cell_folder, ic_substrate_folder, ic_ecm_folder, custom_code_folder, reference_config_variation_id, reference_rulesets_variation_id)
config_variation_ids, rulesets_variation_ids = addVariations(GridVariation(), config_folder, rulesets_collection_folder, EV; reference_variation_id=config_variation_id, reference_rulesets_variation_id=rulesets_variation_id)
sampling = Sampling(monad_min_length, config_folder, rulesets_collection_folder, ic_cell_folder, ic_substrate_folder, ic_ecm_folder, custom_code_folder, config_variation_ids, rulesets_variation_ids)

println("""
############################################
Expand All @@ -106,10 +106,10 @@ println("""
simulation_ids = getSimulations(sampling)
expected_num_sims = monad_min_length
for ev in EV
expected_num_sims *= length(ev.values)
global expected_num_sims *= length(ev.values)
end

@assert length(simulation_ids) == expected_num_sims
@test length(simulation_ids) == expected_num_sims

println("""
############################################
Expand Down

0 comments on commit a3644d4

Please sign in to comment.