Skip to content

Commit 19f2514

Browse files
committed
Merge branch 'master' of github.com:ECP-CANDLE/Supervisor
2 parents 34af17b + c51b4fa commit 19f2514

File tree

6 files changed

+110
-5
lines changed

6 files changed

+110
-5
lines changed

workflows/p1b1_mlrMBO/R/mlrMBO_utils.R

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Utility code to transform elements to strings and vice versa
2+
library(jsonlite)
3+
24
elements_to_string <- function(x){
35
paste0(x,collapse = ",")
46
}
@@ -11,10 +13,9 @@ list_to_string <- function(x){
1113
toString(x)
1214
}
1315

14-
elements_of_lists_to_string <- function(x){
15-
paste0(sapply(x,list_to_string),collapse = ';')
16+
elements_of_lists_to_json <- function(x){
17+
paste0(sapply(x,toJSON,auto_unbox = T),collapse = ';')
1618
}
17-
1819
string_to_list_of_vectors <- function(x){
1920
lapply(unlist(strsplit(x,";")),function(y) as.numeric(unlist(strsplit(y,","))))
2021
}
@@ -31,3 +32,26 @@ result_with_extras_if_exist <- function(res,time_value){
3132
lapply(res, function(x) append_extras_if_exist(c(list(y=x[1]),
3233
list(time=time_value)),x))
3334
}
35+
36+
strsubst <-
37+
function(template, map, verbose=getOption("verbose")) {
38+
pat <- "\\$\\([^\\)]+\\)"
39+
res <- template
40+
map[["$"]] <- "$"
41+
m <- gregexpr(pat, template)
42+
idx <- which(sapply(m, function(x) x[[1]]!=-1)) # faster than 1:length(template)?
43+
for (i in idx) {
44+
line <- template[[i]]
45+
if(verbose) cat("input: |", template[[i]], "|\n")
46+
starts <- m[[i]]
47+
ml <- attr(m[[i]], "match.length")
48+
sym <- substring(line, starts+2, starts+ml-2)
49+
repl <- map[sym]
50+
idx1 <- is.null(repl)
51+
repl[idx1] <- sym[idx1]
52+
norepl <- substring(line, c(1, starts+ml), c(starts-1, nchar(line)))
53+
res[[i]] <- paste(norepl, c(repl, ""), sep="", collapse="") # more elegant?
54+
if (verbose) cat("output: |", res[[i]], "|\n")
55+
}
56+
return(res)
57+
}

workflows/p1b1_mlrMBO/swift/workflow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export PROCS=4
2727
# be ignored if MACHINE flag (see below) is not set
2828
export QUEUE=batch
2929
export WALLTIME=00:10:00
30-
export PPN=16
30+
export PPN=1
3131
export TURBINE_JOBNAME="${EXPID}_job"
3232

3333
# if R cannot be found, then these will need to be
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import p1b3
2+
p1b3.stage_data()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_cellline_expressions.tsv
3+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_cellline_mirna.tsv
4+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_cellline_proteome.tsv
5+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_cellline_kinome.tsv
6+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_drug_descriptors.tsv
7+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_drug_latent.csv
8+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_dose_response.csv
9+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_test_celllines.txt
10+
wget http://ftp.mcs.anl.gov/pub/candle/public/benchmarks/P1B3/P1B3_test_drugs.txt
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
# Check for an optional timeout threshold in seconds. If the duration of the
6+
# model run as executed below, takes longer that this threshhold
7+
# then the run will be aborted. Note that the "timeout" command
8+
# must be supported by executing OS.
9+
10+
# The timeout argument is optional. By default the "run_model" swift
11+
# app fuction sends 3 arguments, and no timeout value is set. If there
12+
# is a 4th (the TIMEOUT_ARG_INDEX) argument, we use that as the timeout value.
13+
14+
# !!! IF YOU CHANGE THE NUMBER OF ARGUMENTS PASSED TO THIS SCRIPT, YOU MUST
15+
# CHANGE THE TIMEOUT_ARG_INDEX !!!
16+
TIMEOUT_ARG_INDEX=4
17+
TIMEOUT=""
18+
if [[ $# == $TIMEOUT_ARG_INDEX ]]
19+
then
20+
TIMEOUT=${!TIMEOUT_ARG_INDEX}
21+
fi
22+
23+
TIMEOUT_CMD=""
24+
if [ -n "$TIMEOUT" ]; then
25+
TIMEOUT_CMD="timeout $TIMEOUT"
26+
fi
27+
28+
# Set param_line from the first argument to this script
29+
# param_line is the string containing the model parameters for a run.
30+
param_file=$1
31+
32+
# Set emews_root to the root directory of the project (i.e. the directory
33+
# that contains the scripts, swift, etc. directories and files)
34+
emews_root=$2
35+
36+
# Each model run, runs in its own "instance" directory
37+
# Set instance_directory to that and cd into it.
38+
instance_directory=$3
39+
cd $instance_directory
40+
41+
# TODO: Define the command to run the model
42+
#VERSION="$(<$emews_root/../Release/version.txt)"
43+
#APP=$emews_root/../Release/transmission_model-$VERSION
44+
#PROPS_FILE=$emews_root/../config/model.props
45+
# TODO configure python correctly
46+
# export PYTHONPATH=$emews_root/python:$benchmark_path
47+
PYTHON="/home/pbalapra/anaconda2/envs/idp/bin/python"
48+
export LD_LIBRARY_PATH="/home/pbalapra/anaconda2/envs/idp/lib"
49+
export PATH="/home/pbalapra/anaconda2/envs/idp/bin:$PATH"
50+
export PYTHONHOME="/home/pbalapra/anaconda2/envs/idp"
51+
export PYTHONPATH="/home/pbalapra/anaconda2/envs/idp/lib/python2.7:/home/ncollier/repos/Benchmarks/Pilot1/P1B3:/home/pbalapra/anaconda2/envs/idp/lib/python2.7/site-packages"
52+
MODEL_CMD="python $emews_root/python/stage_data.py"
53+
54+
# Turn bash error checking off. This is
55+
# required to properly handle the model execution return value
56+
# the optional timeout.
57+
set +e
58+
echo $MODEL_CMD
59+
$TIMEOUT_CMD $MODEL_CMD
60+
# $? is the exit status of the most recently executed command (i.e the
61+
# line above)
62+
RES=$?
63+
if [ "$RES" -ne 0 ]; then
64+
if [ "$RES" == 124 ]; then
65+
echo "---> Timeout error in $MODEL_CMD"
66+
else
67+
echo "---> Error in $MODEL_CMD"
68+
fi
69+
fi

workflows/p1b3_mlrMBO/scripts/theta_run_model.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PYTHON="/home/pbalapra/anaconda2/envs/idp/bin/python"
4848
export LD_LIBRARY_PATH="/home/pbalapra/anaconda2/envs/idp/lib"
4949
export PATH="/home/pbalapra/anaconda2/envs/idp/bin:$PATH"
5050
export PYTHONHOME="/home/pbalapra/anaconda2/envs/idp"
51-
export PYTHONPATH="/home/pbalapra/anaconda2/envs/idp/lib/python2.7:/home/ncollier/repos/Benchmarks/Pilot1/P1B3"
51+
export PYTHONPATH="/home/pbalapra/anaconda2/envs/idp/lib/python2.7:/home/ncollier/repos/Benchmarks/Pilot1/P1B3:/home/pbalapra/anaconda2/envs/idp/lib/python2.7/site-packages"
5252
MODEL_CMD="python $emews_root/python/p1b3_runner.py $param_file $instance_directory"
5353

5454
# Turn bash error checking off. This is

0 commit comments

Comments
 (0)