Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions deploy/docker/cp-tools/base/nextflow/nextflow
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function _expand() { eval "echo \"$1\""; }
CP_NF_WORKDIR=$(_expand "${CP_NF_WORKDIR:-${ANALYSIS_DIR}/work}")
CP_NF_CACHEDIR=$(_expand "${CP_NF_CACHEDIR:-${ANALYSIS_DIR}/cache}")
CP_NF_TRACE_FILE=$(_expand "${CP_NF_TRACE_FILE_DIR:-$CP_NF_WORKDIR}/trace.txt")
CP_NF_TRACE_FIELDS="${CP_NF_TRACE_FIELDS:-"task_id,hash,native_id,process,tag,name,status,exit,module,container,cpus,time,disk,memory,attempt,submit,start,complete,duration,realtime,queue,%cpu,%mem,rss,vmem,peak_rss,peak_vmem,rchar,wchar,syscr,syscw,read_bytes,write_bytes"}"
CP_NF_RUNTIME_DATA_SYNC_PERIOD=${CP_NF_RUNTIME_DATA_SYNC_PERIOD:-300}
CP_NF_RUNTIME_DATA_SYNC_BACKOFF_SEC=10
CP_NF_AUTOGENERATE_PARAMETERS_PATH="${CP_NF_AUTOGENERATE_PARAMETERS_PATH:-$SCRIPTS_DIR/cp_params.json}"
Expand All @@ -76,7 +77,13 @@ mkdir -p "$NXF_WORK"

_ARGS=()
_IS_RUN_COMMAND=
for param in "$@"; do
_NEXTFLOW_CONFIGS=
_NEXTFLOW_CONFIG_OPTION="-c"

while [[ $# -gt 0 ]]; do
param="$1"
shift

if [ "$param" == "run" ]; then
_IS_RUN_COMMAND="1"
fi
Expand All @@ -85,6 +92,17 @@ for param in "$@"; do
CP_NF_WEBLOG_HANDLER_CLEANUP_ON_RUN="1"
continue
fi

if [ "$param" == "-c" ] || [ "$param" == "-C" ]; then
value=$1
_NEXTFLOW_CONFIGS="${value}"
if [ "$param" == "-C" ]; then
_NEXTFLOW_CONFIG_OPTION="-C"
fi
shift
continue
fi

_ARGS+=("$param")
done

Expand Down Expand Up @@ -125,10 +143,19 @@ if [ "$_IS_RUN_COMMAND" == "1" ]; then
echo "weblog.enabled = true" >> $NEXTFLOW_CONFIG
echo "weblog.url = 'http://localhost:${CP_NF_WEBLOG_HANDLER_PORT:-8080}/nextflow/event'" >> $NEXTFLOW_CONFIG
if [ -n "$CP_NF_WORKDIR" ]; then
echo "trace.enabled = true" >> $NEXTFLOW_CONFIG
echo "trace.raw = true" >> $NEXTFLOW_CONFIG
echo "trace.file = \"${CP_NF_TRACE_FILE}\"" >> $NEXTFLOW_CONFIG
echo "trace.fields = 'task_id,hash,native_id,process,tag,name,status,exit,module,container,cpus,time,disk,memory,attempt,submit,start,complete,duration,realtime,queue,%cpu,%mem,rss,vmem,peak_rss,peak_vmem,rchar,wchar,syscr,syscw,read_bytes,write_bytes'" >> $NEXTFLOW_CONFIG
export TRACE_CONFIG="$NXF_HOME/trace.config"
cat > "$TRACE_CONFIG" <<EOF
trace.enabled = true
trace.raw = true
trace.file = "${CP_NF_TRACE_FILE}"
trace.fields = '${CP_NF_TRACE_FIELDS}'
EOF
if [ ! -z "$_NEXTFLOW_CONFIGS" ]; then
_NEXTFLOW_CONFIGS="${_NEXTFLOW_CONFIGS},${TRACE_CONFIG}"
else
_NEXTFLOW_CONFIGS="$TRACE_CONFIG"
fi
echo "[INFO] The Nextflow execution trace file will be created at ${CP_NF_TRACE_FILE}."
fi
fi

Expand All @@ -143,7 +170,9 @@ if [ -f "$NEXTFLOW_CONFIG" ]; then
cat "$NEXTFLOW_CONFIG"
echo
fi
#

# Define final configs configuration (user provided + trace.config if was configured)
_ARGS+=("$_NEXTFLOW_CONFIG_OPTION" "$_NEXTFLOW_CONFIGS")

# Resume parameters
_ARGS+=('-name')
Expand Down