Skip to content

Commit

Permalink
Update Nextflow to 24.10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryHung committed Jan 9, 2025
1 parent aa69a9c commit b7b8121
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GPS Pipeline <!-- omit in toc -->

[![Nextflow](https://img.shields.io/badge/nextflow%20DSL2-24.04.4-23aa62.svg)](https://www.nextflow.io/)
[![Nextflow](https://img.shields.io/badge/nextflow%20DSL2-24.10.3-23aa62.svg)](https://www.nextflow.io/)
[![run with docker](https://img.shields.io/badge/run%20with-docker-0db7ed?labelColor=000000&logo=docker)](https://www.docker.com/)
[![run with singularity](https://img.shields.io/badge/run%20with-singularity-1d355c.svg?labelColor=000000)](https://sylabs.io/singularity/)
[![Launch on Seqera Platform](https://img.shields.io/badge/Launch%20%F0%9F%9A%80-Seqera%20Platform-%234256e7)](https://cloud.seqera.io/quicklaunch?pipeline=https://github.com/GlobalPneumoSeq/gps-pipeline)
Expand Down
85 changes: 66 additions & 19 deletions nextflow
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

[[ "$NXF_DEBUG" == 'x' ]] && set -x
NXF_VER=${NXF_VER:-'24.04.4'}
NXF_VER=${NXF_VER:-'24.10.3'}
NXF_ORG=${NXF_ORG:-'nextflow-io'}
NXF_HOME=${NXF_HOME:-$HOME/.nextflow}
NXF_PROT=${NXF_PROT:-'https'}
Expand All @@ -26,6 +26,43 @@ NXF_CLI="$0 $@"
NXF_CLI_OPTS=${NXF_CLI_OPTS:-}
NXF_REMOTE_DEBUG_PORT=${NXF_REMOTE_DEBUG_PORT:-5005}

function cmp_ver() {
local IFS=.
local i ver1 ver2
read -r -a ver1 <<< "${1//./ }"
read -r -a ver2 <<< "${2//./ }"

# Compare major, minor, and patch numbers
for ((i=0; i<3; i++)); do
ver1[i]=${ver1[i]//[^0-9]}
ver2[i]=${ver2[i]//[^0-9]}
[[ ${ver1[i]:-0} -lt ${ver2[i]:-0} ]] && echo -1 && return
[[ ${ver1[i]:-0} -gt ${ver2[i]:-0} ]] && echo 1 && return
done

# Extract suffixes for comparison
local suffix1="${1##*.}"
local suffix2="${2##*.}"
suffix1="${suffix1//[0-9]}"
suffix2="${suffix2//[0-9]}"

# Compare suffixes
[[ -z $suffix1 && -n $suffix2 ]] && echo 1 && return
[[ -n $suffix1 && -z $suffix2 ]] && echo -1 && return
[[ $suffix1 < $suffix2 ]] && echo -1 && return
[[ $suffix1 > $suffix2 ]] && echo 1 && return

# Versions are equal
echo 0
}

# if the nextflow version is greater or equals to "24.07.0-edge" the new shadow jar launcher
# should be used, otherwise fallback on the legacy behavior setting the variable NXF_LEGACY_LAUNCHER
NXF_LEGACY_LAUNCHER=1
if [[ $(cmp_ver "$NXF_VER" "24.07.0-edge") -ge 0 ]]; then
unset NXF_LEGACY_LAUNCHER
fi

export NXF_CLI
export NXF_ORG
export NXF_HOME
Expand Down Expand Up @@ -147,7 +184,7 @@ function check_latest() {
[[ $cmd != run ]] && return 0
[[ $NXF_OFFLINE == true || $NXF_DISABLE_CHECK_LATEST == true ]] && return 0
local latest=$(get_ver "$NXF_BASE/$(current_ver)/version?current=$NXF_VER")
if [[ -n "$latest" && "$latest" != $NXF_VER ]]; then
if [[ -n "$latest" && $(cmp_ver "$latest" "$NXF_VER") -gt 0 ]]; then
echo_yellow "Nextflow $latest is available - Please consider updating your version to it"
fi
}
Expand Down Expand Up @@ -249,18 +286,19 @@ NXF_JAR=${NXF_JAR:-nextflow-$NXF_VER-$NXF_PACK.jar}
NXF_BIN=${NXF_BIN:-$NXF_DIST/$NXF_VER/$NXF_JAR}
NXF_PATH=$(dirname "$NXF_BIN")
NXF_URL=${NXF_URL:-$NXF_BASE/v$NXF_VER/$NXF_JAR}
NXF_GRAB=${NXF_GRAB:-''}
NXF_CLASSPATH=${NXF_CLASSPATH:-''}
NXF_HOST=${HOSTNAME:-localhost}
[[ $NXF_LAUNCHER ]] || NXF_LAUNCHER=${NXF_HOME}/tmp/launcher/nextflow-${NXF_PACK}_${NXF_VER}/${NXF_HOST}
# both NXF_GRAB and NXF_CLASSPATH are not supported any more as of version 24.04.7-edge
NXF_GRAB=${NXF_GRAB:-''}
NXF_CLASSPATH=${NXF_CLASSPATH:-''}

# Determine the path to this file
if [[ $NXF_PACK = all ]]; then
if [[ $NXF_PACK = dist ]]; then
NXF_BIN=$(which "$0" 2>/dev/null)
[ $? -gt 0 -a -f "$0" ] && NXF_BIN="./$0"
fi

# use nextflow custom java home path
# use nextflow custom java home path
if [[ "$NXF_JAVA_HOME" ]]; then
JAVA_HOME="$NXF_JAVA_HOME"
unset JAVA_CMD
Expand Down Expand Up @@ -311,8 +349,8 @@ else
version_check="^(1.7|1.8)"
version_message="Java 7 or 8"
else
version_check="^(1.8|9|10|11|12|13|14|15|16|17|18|19|20|21|22)"
version_message="Java 8 or later (up to 21)"
version_check="^(1.8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23)"
version_message="Java 8 or later (up to 22)"
fi
if [[ ! $JAVA_VER =~ $version_check ]]; then
echo_red "ERROR: Cannot find Java or it's a wrong version -- please make sure that $version_message is installed"
Expand All @@ -323,8 +361,8 @@ else
fi
exit 1
fi
if [[ ! $JAVA_VER =~ ^(11|12|13|14|15|16|17|18|19|20|21|22) ]]; then
echo_yellow "NOTE: Nextflow is not tested with Java $JAVA_VER -- It's recommended the use of version 11 up to 22\n"
if [[ ! $JAVA_VER =~ ^(11|12|13|14|15|16|17|18|19|20|21|22|23) ]]; then
echo_yellow "NOTE: Nextflow is not tested with Java $JAVA_VER -- It's recommended the use of version 11 up to 23\n"
fi
mkdir -p "$(dirname "$JAVA_KEY")"
[[ -f $JAVA_VER ]] && echo $JAVA_VER > "$JAVA_KEY"
Expand All @@ -346,10 +384,11 @@ if [[ $cmd == console ]]; then bg=1;
else JAVA_OPTS+=(-Djava.awt.headless=true)
fi

[[ "$JAVA_VER" =~ ^(21|22) ]] && [[ ! "$NXF_ENABLE_VIRTUAL_THREADS" ]] && NXF_ENABLE_VIRTUAL_THREADS=true
[[ "$JAVA_HOME" ]] && JAVA_OPTS+=(-Dcapsule.java.home="$JAVA_HOME")
[[ "$CAPSULE_LOG" ]] && JAVA_OPTS+=(-Dcapsule.log=$CAPSULE_LOG)
[[ "$CAPSULE_RESET" ]] && JAVA_OPTS+=(-Dcapsule.reset=true)
if [[ $NXF_LEGACY_LAUNCHER ]]; then
[[ "$JAVA_HOME" ]] && JAVA_OPTS+=(-Dcapsule.java.home="$JAVA_HOME")
[[ "$CAPSULE_LOG" ]] && JAVA_OPTS+=(-Dcapsule.log=$CAPSULE_LOG)
[[ "$CAPSULE_RESET" ]] && JAVA_OPTS+=(-Dcapsule.reset=true)
fi
[[ "$cmd" != "run" && "$cmd" != "node" ]] && JAVA_OPTS+=(-XX:+TieredCompilation -XX:TieredStopAtLevel=1)
[[ "$NXF_OPTS" ]] && JAVA_OPTS+=($NXF_OPTS)
[[ "$NXF_CLASSPATH" ]] && export NXF_CLASSPATH
Expand Down Expand Up @@ -401,9 +440,14 @@ LAUNCH_FILE="${NXF_LAUNCHER}/classpath-$(env_md5)"
if [ -s "$LAUNCH_FILE" ] && [ "$LAUNCH_FILE" -nt "$NXF_BIN" ] && [[ "$remote_debug" -ne 1 ]]; then
declare -a launcher="($(cat "$LAUNCH_FILE"))"
else
# otherwise run the capsule and get the result classpath in the 'launcher' and save it to a file
cli=($("$JAVA_CMD" "${JAVA_OPTS[@]}" -jar "$NXF_BIN"))
[[ $? -ne 0 ]] && echo_red 'Unable to initialize nextflow environment' && exit 1
if [[ $NXF_LEGACY_LAUNCHER ]]; then
# otherwise run the capsule and get the result classpath in the 'launcher' and save it to a file
cli=($("$JAVA_CMD" "${JAVA_OPTS[@]}" -jar "$NXF_BIN"))
[[ $? -ne 0 ]] && echo_red 'Unable to initialize nextflow environment' && exit 1
else
# otherwise parse the command and get the result classpath in the 'launcher' and save it to a file
cli=("\"$JAVA_CMD\"" "${JAVA_OPTS[@]}" -jar "$NXF_BIN")
fi

# first string between double quotes is the full path to java, also blank spaces are included
# remainder string are arguments
Expand All @@ -417,7 +461,7 @@ else
[[ "$NXF_JVM_ARGS" ]] && launcher+=($NXF_JVM_ARGS)
[[ "$remote_debug" ]] && launcher+=(-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=$NXF_REMOTE_DEBUG_PORT)

if [[ "$JAVA_VER" =~ ^(9|10|11|12|13|14|15|16|17|18|19|20|21|22) ]]; then
if [[ "$JAVA_VER" =~ ^(9|10|11|12|13|14|15|16|17|18|19|20|21|22|23) ]]; then
launcher+=(--add-opens=java.base/java.lang=ALL-UNNAMED)
launcher+=(--add-opens=java.base/java.io=ALL-UNNAMED)
launcher+=(--add-opens=java.base/java.nio=ALL-UNNAMED)
Expand All @@ -437,14 +481,16 @@ else
launcher+=(--add-opens=java.base/java.util.regex=ALL-UNNAMED)
if [[ "$NXF_ENABLE_VIRTUAL_THREADS" == 'true' ]]; then
if [[ "$JAVA_VER" =~ ^(19|20) ]]; then launcher+=(--enable-preview)
elif [[ ! "$JAVA_VER" =~ ^(21|22) ]]; then die "Virtual threads require Java 19 or later - current version $JAVA_VER"
elif [[ ! "$JAVA_VER" =~ ^(21|22|23) ]]; then die "Virtual threads require Java 19 or later - current version $JAVA_VER"
fi
fi
launcher+=("${cmd_tail[@]}")
else
launcher+=("${cmd_tail[@]}")
fi

# create the launch file only when using the legacy launcher (capsule)
if [[ $NXF_LEGACY_LAUNCHER ]]; then
# Don't show errors if the LAUNCH_FILE can't be created
if mkdir -p "${NXF_LAUNCHER}" 2>/dev/null; then
STR=''
Expand All @@ -455,6 +501,7 @@ else
else
echo_yellow "Warning: Couldn't create cached classpath folder: $NXF_LAUNCHER -- Maybe NXF_HOME is not writable?"
fi
fi

fi

Expand Down

0 comments on commit b7b8121

Please sign in to comment.