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
28 changes: 17 additions & 11 deletions submit-nextflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -180,12 +186,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

Expand All @@ -205,7 +211,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
Expand Down Expand Up @@ -255,7 +261,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
Expand Down Expand Up @@ -283,11 +289,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
Loading