From 3f1e1013e2d82246d5c86b03653939e37e173a4f Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Thu, 17 Sep 2026 11:27:32 -0400 Subject: [PATCH 1/2] Always resume in generated resubmit.sh; fix blank cache dir output resubmit.sh previously only included --resume if the original submission already used it, defeating its purpose of continuing an interrupted run. Also fixes the cache-directory messages and resubmit.sh header comment, which referenced NXF_CACHE_DIR (only set inside the sbatch job) instead of NEXTFLOW_CACHE_DIR, printing blank/literal placeholders. Co-Authored-By: Claude Sonnet 5 --- submit-nextflow.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/submit-nextflow.sh b/submit-nextflow.sh index de8fa3e..a2277ee 100644 --- a/submit-nextflow.sh +++ b/submit-nextflow.sh @@ -180,12 +180,12 @@ RESUBMIT_SCRIPT="$OUTPUT_DIR/resubmit.sh" generate_resubmit_script() { local script_path=$(readlink -f "$0") - cat > "$RESUBMIT_SCRIPT" << 'RESUBMIT_EOF' + cat > "$RESUBMIT_SCRIPT" << RESUBMIT_EOF #!/bin/bash # Auto-generated resubmit script # Created: $(date) -# Cache Directory: $NXF_CACHE_DIR -# Original command parameters saved for exact resubmission +# Cache Directory: $NEXTFLOW_CACHE_DIR +# Original command parameters saved for resubmission, with --resume added RESUBMIT_EOF @@ -205,7 +205,7 @@ RESUBMIT_EOF echo " -m \"$MEMORY\" \\" >> "$RESUBMIT_SCRIPT" echo " --partition \"$PARTITION\" \\" >> "$RESUBMIT_SCRIPT" echo " --qos \"$QOS\" \\" >> "$RESUBMIT_SCRIPT" - [[ -n "$RESUME" ]] && echo " --resume \\" >> "$RESUBMIT_SCRIPT" + echo " --resume \\" >> "$RESUBMIT_SCRIPT" # Add additional arguments if any if [[ ${#ADDITIONAL_ARGS[@]} -gt 0 ]]; then @@ -255,7 +255,7 @@ if [[ "$DRY_RUN" == true ]]; then # Inform user of cache directory echo "" - echo "Would use cache directory: $NXF_CACHE_DIR" + echo "Would use cache directory: $NEXTFLOW_CACHE_DIR" # Generate resubmit script even in dry-run mode generate_resubmit_script @@ -283,11 +283,11 @@ else # Inform user of cache directory echo "" - echo "Using cache directory: $NXF_CACHE_DIR" + echo "Using cache directory: $NEXTFLOW_CACHE_DIR" # Generate resubmit script after successful submission generate_resubmit_script echo "" echo "Resubmit script saved to: $RESUBMIT_SCRIPT" - echo "To resubmit with identical parameters, run: $RESUBMIT_SCRIPT" + echo "To resubmit (with --resume), run: $RESUBMIT_SCRIPT" fi From 8f0cb49934fcf58b45c0a3fa54bff4514e909181 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Thu, 17 Sep 2026 11:38:11 -0400 Subject: [PATCH 2/2] Key Nextflow cache dir on resolved --output dir, not launch directory The cache-dir hash was based on pwd, so resuming only worked if you invoked submit-nextflow.sh/resubmit.sh from the exact same directory (and the same symlink path into it) as the original submission. Since --output/-o is a required argument that's already identical between the original submission and any later resubmit.sh run, hash its resolved physical path instead. This makes --resume work regardless of which directory or symlink either script is invoked from. Co-Authored-By: Claude Sonnet 5 --- submit-nextflow.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/submit-nextflow.sh b/submit-nextflow.sh index a2277ee..5858199 100644 --- a/submit-nextflow.sh +++ b/submit-nextflow.sh @@ -58,11 +58,12 @@ INPUT_BATCH="" OUTPUT_DIR="" ADDITIONAL_ARGS=() NEXTFLOW_MODULE_VERSION="stable" -# Put the nextflow cache into a unique directory associated with the launch directory. -# e.g. /flashscratch/aberger/$HASH/.nextflow where $HASH is the md5sum of the full -# path of the directory that nextflow was launched from. +# Put the nextflow cache into a unique directory associated with the output directory. +# e.g. /flashscratch/aberger/$HASH/.nextflow where $HASH is the md5sum of the resolved, +# physical path of --output/-o. This (rather than the launch directory) is what stays +# identical between the original submission and any later resubmit.sh run, regardless +# of which directory or symlink you invoke either script from. NEXTFLOW_CACHE_DIR_ROOT="/flashscratch/$USER" -NEXTFLOW_CACHE_DIR="$NEXTFLOW_CACHE_DIR_ROOT/$(pwd | md5sum | cut -d' ' -f1)/.nextflow" # Parse command line arguments while [[ $# -gt 0 ]]; do @@ -169,6 +170,11 @@ fi # Create output directory if it doesn't exist mkdir -p "$OUTPUT_DIR" +# Compute the cache directory from the resolved output directory (see comment above +# NEXTFLOW_CACHE_DIR_ROOT), now that OUTPUT_DIR exists and can be resolved. +OUTPUT_DIR_ABS="$(cd "$OUTPUT_DIR" && pwd -P)" +NEXTFLOW_CACHE_DIR="$NEXTFLOW_CACHE_DIR_ROOT/$(echo -n "$OUTPUT_DIR_ABS" | md5sum | cut -d' ' -f1)/.nextflow" + # Build the revision flag if specified REVISION_FLAG="" if [[ -n "$REVISION" ]]; then