Skip to content

Commit

Permalink
Merge pull request #39 from laurentheirendt/seminar
Browse files Browse the repository at this point in the history
Adding keyword to optionally use the CT in PALM
  • Loading branch information
laurentheirendt authored Oct 1, 2018
2 parents 25e8357 + 13ac7ce commit 305456c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions src/PALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ See also: `loopModels()` and `shareLoad()`
"""

function PALM(dir, scriptName, nMatlab::Int=2, outputFile::AbstractString="PALM_data.mat", varsCharact=[], cobraToolboxDir=ENV["HOME"]*Base.Filesystem.path_separator*"cobratoolbox", printLevel::Int=1)
function PALM(dir, scriptName; nMatlab::Int=2, outputFile::AbstractString="PALM_data.mat", varsCharact=[], cobraToolboxDir=ENV["HOME"]*Base.Filesystem.path_separator*"cobratoolbox", printLevel::Int=1, useCOBRA::Bool=true)

# read the content of the directory
dirContent = readdir(dir)
Expand Down Expand Up @@ -269,11 +269,13 @@ function PALM(dir, scriptName, nMatlab::Int=2, outputFile::AbstractString="PALM_
# declare an empty array for storing a summary of all data
summaryData = Array{Union{Int,Float64,AbstractString}}(nModels + 1, nCharacteristics + 1)

for (p, pid) in enumerate(workers())
@spawnat (p + 1) begin
# clone a copy to a tmp folder as the cobtratoolbox is updated at runtime
if !isdir("/tmp/test-ct-$p")
run(`git clone $cobraToolboxDir /tmp/test-ct-$p`)
if useCOBRA
for (p, pid) in enumerate(workers())
@spawnat (p + 1) begin
# clone a copy to a tmp folder as the cobtratoolbox is updated at runtime
if !isdir("/tmp/test-ct-$p")
run(`git clone $cobraToolboxDir /tmp/test-ct-$p`)
end
end
end
end
Expand All @@ -285,13 +287,14 @@ function PALM(dir, scriptName, nMatlab::Int=2, outputFile::AbstractString="PALM_
info("Launching MATLAB session on worker $(p+1).")
end

# adding the model directory and eventual subdirectories to the MATLAB path
# Note: the fileseparator `/` also works on Windows systems if git Bash has been installed
@async R[p] = @spawnat (p+1) begin
eval(parse("mat\"addpath(genpath('/tmp/test-ct-$p'))\""))
eval(parse("mat\"run('/tmp/test-ct-$p/initCobraToolbox.m');\""))
if useCOBRA
# adding the model directory and eventual subdirectories to the MATLAB path
# Note: the fileseparator `/` also works on Windows systems if git Bash has been installed
@async R[p] = @spawnat (p+1) begin
eval(parse("mat\"addpath(genpath('/tmp/test-ct-$p'))\""))
eval(parse("mat\"run('/tmp/test-ct-$p/initCobraToolbox.m');\""))
end
end

end

# print an informative message
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if sizeof(Pkg.installed("MATLAB")) > 0
"nNz"]

# launch PALM with the scriptFile on the 2 models
PALM(joinpath(TESTDIR, "testModels"), "scriptFile", 2, "modelCharacteristics.mat", varsCharact, "/tmp/cobratoolbox-cobrajl")
PALM(joinpath(TESTDIR, "testModels"), "scriptFile", nMatlab=2, outputFile="modelCharacteristics.mat", varsCharact=varsCharact, cobraToolboxDir="/tmp/cobratoolbox-cobrajl")

# remove the directory with the test models
rm(joinpath(TESTDIR, "testModels"), force=true, recursive=true)
Expand Down

0 comments on commit 305456c

Please sign in to comment.