Skip to content

Commit 46ab1d4

Browse files
authored
Merge pull request #116 from KumarLabJax/task/sumner2-qol-improvements
Improvements to submit script and fixes/improvements to sumner2 profile
2 parents 0cd5865 + 080cb48 commit 46ab1d4

File tree

2 files changed

+89
-11
lines changed

2 files changed

+89
-11
lines changed

nextflow/configs/profiles/sumner2.config

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// sumner2 configuration file
22

33
workDir = "/flashscratch/${USER}/nextflow-work"
4+
timeline.enabled = true
5+
trace.enabled = true
6+
report.enabled = true
7+
dag.enabled = true
48

59
params {
610
/*
@@ -32,7 +36,7 @@ params {
3236
support_code_dir = "/workspace/support_code/"
3337
heuristic_classifier_folder = "/opt/JABS-postprocess/src/jabs_postprocess/heuristic_classifiers/"
3438
filter_processed = false
35-
model_dir = "/projects/kumar-lab/multimouse-pipeline/nextflow-artifacts/neural_net_models/"
39+
model_dir = "/projects/kumar-lab/data/neural-net-models/"
3640

3741
jabs_version = "v0.37.0"
3842
classifier_window_sizes = [2, 5, 10, 20, 30, 60]
@@ -456,10 +460,10 @@ process {
456460
cpus = 2
457461
// 8.53 GB * num_mice
458462
memory = {
459-
def per_mouse_gb = 10
463+
def per_mouse_gb = 11
460464
def base = params.num_mice * per_mouse_gb
461465
def retry_factor = 1 + (0.5 * (task.attempt - 1))
462-
def uncapped_memory = (base * retry_factor).toInt
466+
def uncapped_memory = (base * retry_factor).toInteger()
463467
return Math.min(uncapped_memory, 128) + '.GB'
464468
}
465469
time = { 5.hours * task.attempt }
@@ -560,9 +564,7 @@ process {
560564

561565
executor {
562566
name = 'slurm'
563-
// The number of tasks the executor will handle in a parallel manner
564-
// TODO: This limit is set low to be a good GPU-cluster citizen. CPUs don't need to be as restricted.
565-
queueSize = 24
566-
submitRateLimit = '1 s'
567-
// Determines the max rate of job submission per time unit, for example '10sec' eg. max 10 jobs per second or '1/2 s' i.e. 1 job submissions every 2 seconds.
567+
submitRateLimit = '2 s'
568+
// Determines the max rate of job submission per time unit, for example '10sec'
569+
// eg. max 10 jobs per second or '1/2 s' i.e. 1 job submissions every 2 seconds.
568570
}

submit-nextflow.sh

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ EOF
4444

4545
# Default values
4646
PIPELINE="KumarLabJax/mouse-tracking-runtime"
47-
REVISION="v0.2.0"
47+
REVISION="stable"
4848
WORKFLOW="single-mouse"
4949
PROFILE="sumner2"
5050
JOB_NAME="KL_Tracking_Nextflow"
@@ -57,6 +57,12 @@ DRY_RUN=false
5757
INPUT_BATCH=""
5858
OUTPUT_DIR=""
5959
ADDITIONAL_ARGS=()
60+
NEXTFLOW_MODULE_VERSION="stable"
61+
# Put the nextflow cache into a unique directory associated with the launch directory.
62+
# e.g. /flashscratch/aberger/$HASH/.nextflow where $HASH is the md5sum of the full
63+
# path of the directory that nextflow was launched from.
64+
NEXTFLOW_CACHE_DIR_ROOT="/flashscratch/$USER"
65+
NEXTFLOW_CACHE_DIR="$NEXTFLOW_CACHE_DIR_ROOT/$(pwd | md5sum | cut -d' ' -f1)/.nextflow"
6066

6167
# Parse command line arguments
6268
while [[ $# -gt 0 ]]; do
@@ -169,6 +175,55 @@ if [[ -n "$REVISION" ]]; then
169175
REVISION_FLAG="-r $REVISION"
170176
fi
171177

178+
# Generate resubmit.sh script
179+
RESUBMIT_SCRIPT="$OUTPUT_DIR/resubmit.sh"
180+
generate_resubmit_script() {
181+
local script_path=$(readlink -f "$0")
182+
183+
cat > "$RESUBMIT_SCRIPT" << 'RESUBMIT_EOF'
184+
#!/bin/bash
185+
# Auto-generated resubmit script
186+
# Created: $(date)
187+
# Cache Directory: $NXF_CACHE_DIR
188+
# Original command parameters saved for exact resubmission
189+
190+
RESUBMIT_EOF
191+
192+
# Add the actual command with all parameters
193+
echo -n "\"$script_path\" \\" >> "$RESUBMIT_SCRIPT"
194+
echo "" >> "$RESUBMIT_SCRIPT"
195+
196+
# Add all the parameters
197+
echo " -i \"$INPUT_BATCH\" \\" >> "$RESUBMIT_SCRIPT"
198+
echo " -o \"$OUTPUT_DIR\" \\" >> "$RESUBMIT_SCRIPT"
199+
echo " -n \"$PIPELINE\" \\" >> "$RESUBMIT_SCRIPT"
200+
[[ -n "$REVISION" ]] && echo " -r \"$REVISION\" \\" >> "$RESUBMIT_SCRIPT"
201+
echo " -w \"$WORKFLOW\" \\" >> "$RESUBMIT_SCRIPT"
202+
echo " -p \"$PROFILE\" \\" >> "$RESUBMIT_SCRIPT"
203+
echo " -j \"$JOB_NAME\" \\" >> "$RESUBMIT_SCRIPT"
204+
echo " -t \"$TIME_LIMIT\" \\" >> "$RESUBMIT_SCRIPT"
205+
echo " -m \"$MEMORY\" \\" >> "$RESUBMIT_SCRIPT"
206+
echo " --partition \"$PARTITION\" \\" >> "$RESUBMIT_SCRIPT"
207+
echo " --qos \"$QOS\" \\" >> "$RESUBMIT_SCRIPT"
208+
[[ -n "$RESUME" ]] && echo " --resume \\" >> "$RESUBMIT_SCRIPT"
209+
210+
# Add additional arguments if any
211+
if [[ ${#ADDITIONAL_ARGS[@]} -gt 0 ]]; then
212+
echo -n " -- " >> "$RESUBMIT_SCRIPT"
213+
for arg in "${ADDITIONAL_ARGS[@]}"; do
214+
echo -n "\"$arg\" " >> "$RESUBMIT_SCRIPT"
215+
done
216+
echo "\\" >> "$RESUBMIT_SCRIPT"
217+
fi
218+
219+
# Remove the last backslash
220+
sed -i '$ s/ \\$//' "$RESUBMIT_SCRIPT"
221+
echo "" >> "$RESUBMIT_SCRIPT"
222+
223+
# Make it executable
224+
chmod +x "$RESUBMIT_SCRIPT"
225+
}
226+
172227
# Generate the sbatch script content
173228
SBATCH_SCRIPT=$(cat << EOF
174229
#!/bin/bash
@@ -182,7 +237,9 @@ SBATCH_SCRIPT=$(cat << EOF
182237
183238
# LOAD NEXTFLOW
184239
module use --append /projects/kumar-lab/meta/modules
185-
module load nextflow/stable
240+
module load nextflow/$NEXTFLOW_MODULE_VERSION
241+
242+
export NXF_CACHE_DIR="$NEXTFLOW_CACHE_DIR"
186243
187244
# RUN NEXTFLOW PIPELINE
188245
nextflow run $PIPELINE $REVISION_FLAG -profile $PROFILE --input_batch $INPUT_BATCH --workflow $WORKFLOW --pubdir $OUTPUT_DIR $RESUME $(printf " %s" "${ADDITIONAL_ARGS[@]}")
@@ -194,6 +251,15 @@ if [[ "$DRY_RUN" == true ]]; then
194251
echo "$SBATCH_SCRIPT"
195252
echo "=============================================="
196253
echo "Command that would be executed: sbatch <<< \"\$SBATCH_SCRIPT\""
254+
echo ""
255+
256+
# Inform user of cache directory
257+
echo ""
258+
echo "Would use cache directory: $NXF_CACHE_DIR"
259+
260+
# Generate resubmit script even in dry-run mode
261+
generate_resubmit_script
262+
echo "Resubmit script would be saved to: $RESUBMIT_SCRIPT"
197263
else
198264
# Submit the job
199265
echo "Submitting Nextflow pipeline with the following parameters:"
@@ -214,4 +280,14 @@ else
214280

215281
# Submit using here-string to avoid temporary files
216282
sbatch <<< "$SBATCH_SCRIPT"
217-
fi
283+
284+
# Inform user of cache directory
285+
echo ""
286+
echo "Using cache directory: $NXF_CACHE_DIR"
287+
288+
# Generate resubmit script after successful submission
289+
generate_resubmit_script
290+
echo ""
291+
echo "Resubmit script saved to: $RESUBMIT_SCRIPT"
292+
echo "To resubmit with identical parameters, run: $RESUBMIT_SCRIPT"
293+
fi

0 commit comments

Comments
 (0)