Skip to content

Commit e2ff6ef

Browse files
authored
Merge pull request #54 from KumarLabJax/remote-nextflow-hooks
Remote nextflow hooks
2 parents 192740d + 98152e6 commit e2ff6ef

File tree

11 files changed

+436
-157
lines changed

11 files changed

+436
-157
lines changed

main.nf

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,70 +10,16 @@ include { SINGLE_MOUSE_TRACKING; SPLIT_BY_CORNERS } from './nextflow/workflows/s
1010
include { SINGLE_MOUSE_V2_FEATURES; SINGLE_MOUSE_V6_FEATURES } from './nextflow/workflows/feature_generation'
1111
include { MULTI_MOUSE_TRACKING } from './nextflow/workflows/multi_mouse_pipeline'
1212
include { MANUALLY_CORRECT_CORNERS; INTEGRATE_CORNER_ANNOTATIONS } from './nextflow/workflows/sleap_manual_correction'
13-
include { ADD_DUMMY_VIDEO; validateInputFile } from './nextflow/modules/utils'
14-
15-
/*
16-
* Convert input_batch into a single list
17-
*/
18-
all_files = []
19-
invalid_files = []
20-
valid_files = []
21-
22-
if (params.input_batch != null) {
23-
def batch_lines = file(params.input_batch).text.readLines()
24-
25-
// Validate each file in the batch
26-
batch_lines.each { file_path ->
27-
def (is_valid, error_message) = validateInputFile(file_path, params.workflow)
28-
29-
if (is_valid) {
30-
valid_files.add(file_path)
31-
} else {
32-
invalid_files.add([file_path, error_message])
33-
}
34-
}
35-
36-
// Report any invalid files
37-
if (invalid_files.size() > 0) {
38-
println "The following files failed validation:"
39-
invalid_files.each { file_path, error_message ->
40-
println " - ${error_message}"
41-
}
42-
43-
if (!params.ignore_invalid_inputs) {
44-
println "Please check the input files and try again."
45-
println "If you want to ignore invalid inputs, please set the parameter ignore_invalid_inputs to true."
46-
System.exit(1)
47-
}
48-
49-
// If all files are invalid, exit
50-
if (valid_files.size() == 0) {
51-
println "No valid files to process. Exiting."
52-
System.exit(1)
53-
}
54-
55-
// Otherwise, continue with valid files and warn the user
56-
println "Continuing with ${valid_files.size()} valid files out of ${batch_lines.size()} total files."
57-
}
58-
59-
all_files.addAll(valid_files)
60-
}
61-
62-
if (all_files.size() == 0){
63-
println "Missing any data to process, please assign either input_data or input_batch"
64-
System.exit(1)
65-
}
13+
include { ADD_DUMMY_VIDEO } from './nextflow/modules/utils'
6614

6715
/*
6816
* Run the selected workflow
6917
*/
7018
workflow{
71-
// Download the data locally if necessary
72-
PREPARE_DATA(Channel.fromList(all_files), params.location)
73-
7419
// Generate pose files
7520
if (params.workflow == "single-mouse"){
76-
SINGLE_MOUSE_TRACKING(PREPARE_DATA.out.out_file)
21+
PREPARE_DATA(params.input_batch, params.location, false)
22+
SINGLE_MOUSE_TRACKING(PREPARE_DATA.out.file_processing_channel)
7723
v2_outputs = SINGLE_MOUSE_TRACKING.out[0]
7824
all_v6_outputs = SINGLE_MOUSE_TRACKING.out[1]
7925
// Split and publish pose_v6 files depending on if corners were successful
@@ -93,22 +39,24 @@ workflow{
9339
if (params.workflow == "single-mouse-corrected-corners"){
9440
// Integrate annotations back into pose files
9541
// This branch requires files to be local and already url-ified
96-
// Use a channel of `all_files` instead of `PREPARE_DATA.out.out_file`
97-
INTEGRATE_CORNER_ANNOTATIONS(Channel.fromList(all_files), params.sleap_file)
42+
PREPARE_DATA(params.input_batch, params.location, true)
43+
INTEGRATE_CORNER_ANNOTATIONS(PREPATE_DATA.out.file_processing_channel, params.sleap_file)
9844
ADD_DUMMY_VIDEO(INTEGRATE_CORNER_ANNOTATIONS.out, params.clip_duration)
9945
paired_video_and_pose = ADD_DUMMY_VIDEO.out[0]
10046

10147
// Pose v6 features
10248
SINGLE_MOUSE_V6_FEATURES(paired_video_and_pose)
10349
}
10450
if (params.workflow == "single-mouse-v6-features"){
51+
PREPARE_DATA(params.input_batch, params.location, false)
10552
// Generate features from pose_v6 files
10653
ADD_DUMMY_VIDEO(PREPARE_DATA.out.out_file, params.clip_duration)
10754
paired_video_and_pose = ADD_DUMMY_VIDEO.out[0]
10855
SINGLE_MOUSE_V6_FEATURES(paired_video_and_pose)
10956
}
11057
if (params.workflow == "multi-mouse"){
111-
MULTI_MOUSE_TRACKING(PREPARE_DATA.out.video_file, params.num_mice)
58+
PREPARE_DATA(params.input_batch, params.location, false)
59+
MULTI_MOUSE_TRACKING(PREPARE_DATA.out.file_processing_channel, params.num_mice)
11260
}
11361
}
11462

nextflow/configs/profiles/development.config

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
// development configuration file
22

3-
workDir = "/media/bgeuther/Storage/TempStorage/onnx/onnx-pipelines/work/"
3+
artifact_dir = "/media/bgeuther/LL3_Internal/nextflow-artifacts/"
4+
workDir = "${artifact_dir}nextflow-work/cache/"
45

56
params {
67
/*
78
* Additional Parameters for the development profile
89
* These parameters are described in the sumner2 profile
910
*/
10-
pubdir = "/media/bgeuther/Storage/TempStorage/onnx/nf-tests"
11+
pubdir = "${artifact_dir}nextflow-work/pubdir/"
1112
tracking_code_dir = "/kumar_lab_models/mouse-tracking-runtime/"
1213
gait_code_dir = "/gait-analysis/"
1314
vfi_code_dir = "/vfi/Code/"
1415
support_code_dir = "/mouse-tracking-runtime/support_code/"
1516
heuristic_classifier_folder = "/JABS-postprocess/heuristic_classifiers/"
17+
filter_processed = false
1618

1719
jabs_version = "0.18.1"
18-
classifier_project_folders = "/media/bgeuther/Storage/TempStorage/jabs-classifiers/project_folders/"
19-
classifier_training_file_folder = "/media/bgeuther/Storage/TempStorage/jabs-classifiers/training_files/"
20-
exported_classifier_folder = "/media/bgeuther/Storage/TempStorage/jabs-classifiers/exported_classifiers/"
20+
classifier_project_folders = "${artifact_dir}jabs-classifiers/project_folders/"
21+
classifier_training_file_folder = "${artifact_dir}jabs-classifiers/training_files/"
22+
exported_classifier_folder = "${artifact_dir}jabs-classifiers/exported_classifiers/"
2123
classifier_artifact_suffix = "_classifier_v${jabs_version}.pickle"
2224
classifier_window_sizes = [2, 5, 10, 20, 30, 60]
2325
// Classifiers are described as behavior_name: project_folder
@@ -93,6 +95,12 @@ params {
9395
// Some default parameters for branches in the pipeline
9496
default_feature_input = ["${projectDir}/nextflow/default-data/DEFAULT_VIDEO.mp4", "${projectDir}/nextflow/default-data/DEFAULT_VIDEO_pose_est_v6.h5"]
9597
default_manual_correction_input = default_feature_input
98+
99+
// Remote storage parameters
100+
globus_compute_endpoint = "INVALID" // Personal endpoint where compute filesystem is visible
101+
globus_remote_endpoint = "70850914-722d-11e7-aa01-22000bf2d287" // JAX T2 storage endpoint
102+
globus_remote_folder = "/tier2/vkumar/"
103+
dropbox_prefix = "labdropbox:\"/KumarLab's shared workspace/VideoData/MDS_Tests/\""
96104
}
97105

98106
singularity {
@@ -117,33 +125,34 @@ process {
117125
* Runtime options
118126
*/
119127
withLabel: "tracking" {
120-
container = "/media/bgeuther/Storage/TempStorage/onnx/onnx-pipelines/vm/deployment-runtime_2025-03-05.sif"
128+
container = "${artifact_dir}vms/deployment-runtime_2025-03-05.sif"
121129
}
122130
withLabel: "jabs_classify" {
123-
container = "/media/bgeuther/Storage/TempStorage/JABS-GUI_2025-02-12_v0.18.1.sif"
131+
container = "${artifact_dir}vms/JABS-GUI_2025-02-12_v0.18.1.sif"
124132
// Classifiers exist in a folder not bound by default
125133
containerOptions = "-B /media"
126134
}
127135
withLabel: "jabs_postprocess" {
128-
container = "/media/bgeuther/Storage/TempStorage/JABS-Postprocessing-2025-03-27_864d687.sif"
136+
container = "${artifact_dir}vms/JABS-Postprocessing-2025-03-27_864d687.sif"
129137
}
130138
withLabel: "jabs_table_convert" {
131-
container = "/media/bgeuther/Storage/TempStorage/onnx/onnx-pipelines/vm/support-r-code_2025-02-11.sif"
139+
container = "${artifact_dir}vms/support-r-code_2025-02-11.sif"
132140
}
133141
withLabel: "gait" {
134-
container = "/media/bgeuther/Storage/TempStorage/onnx/onnx-pipelines/tests/gait/gaitanalysis/vm/gait-pipeline-2025-03-27.sif"
142+
container = "${artifact_dir}vms/gait-pipeline-2025-03-27.sif"
135143
}
136144
withLabel: "frailty" {
137-
container = "/media/bgeuther/Storage/TempStorage/onnx/onnx-pipelines/tests/vfi/vFI-features/vm/vfi-2025-03-27.sif"
145+
container = "${artifact_dir}vms/vfi-2025-03-27.sif"
138146
}
139147
withLabel: "sleap" {
140-
container = "/media/bgeuther/Storage/TempStorage/onnx/onnx-pipelines/vm/sleap-1.4.1.sif"
148+
container = "${artifact_dir}vms/sleap-1.4.1.sif"
141149
}
142150
withLabel: "sleap_io" {
143-
container = "/media/bgeuther/Storage/TempStorage/onnx/onnx-pipelines/vm/sleap-io-0.2.0.sif"
151+
container = "${artifact_dir}vms/sleap-io-0.2.0.sif"
144152
}
145-
withLabel: "dropbox" {
146-
DROPBOX_PREFIX = "labdropbox:KumarLab's shared workspace/VideoData/MDS_Tests"
153+
withLabel: "globus" {
154+
container = "${artifact_dir}vms/globus-cli_2025-07-22.sif"
155+
containerOptions = "-B /media"
147156
}
148157
}
149158

nextflow/configs/profiles/sumner2.config

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ params {
1111
* - vfi_code_dir: prefix for the vfi code directory
1212
* - support_code_dir: prefix for the support code directory
1313
* - heuristic_classifier_folder: prefix for the heuristic classifier folder
14+
* - filter_processed: whether to filter processed files in the batch
1415

1516
* - jabs_version: version of JABS used for the classifiers
1617
* - classifier_project_folders: directory containing the classifier project folders
@@ -34,6 +35,7 @@ params {
3435
vfi_code_dir = "/vfi/Code/"
3536
support_code_dir = "/mouse-tracking-runtime/support_code/"
3637
heuristic_classifier_folder = "/JABS-postprocess/heuristic_classifiers/"
38+
filter_processed = false
3739

3840
jabs_version = "0.18.1"
3941
classifier_project_folders = "/projects/kumar-lab/multimouse-pipeline/nextflow-artifacts/project_folders/"
@@ -113,6 +115,12 @@ params {
113115
// Some default parameters for branches in the pipeline
114116
default_feature_input = ["/projects/kumar-lab/meta/default-data/DEFAULT_VIDEO.mp4", "/projects/kumar-lab/meta/default-data/DEFAULT_VIDEO_pose_est_v6.h5"]
115117
default_manual_correction_input = default_feature_input
118+
119+
// Remote storage parameters
120+
globus_compute_endpoint = "b8377de1-47c2-11e7-bd5c-22000b9a448b" // JAX endpoint where compute filesystem is visible
121+
globus_remote_endpoint = "70850914-722d-11e7-aa01-22000bf2d287" // JAX T2 storage endpoint
122+
globus_remote_folder = "/tier2/vkumar/"
123+
dropbox_prefix = "labdropbox:\"/KumarLab's shared workspace/VideoData/MDS_Tests/\""
116124
}
117125

118126
apptainer {
@@ -166,6 +174,10 @@ process {
166174
queue = "compute"
167175
resourceLimits = [ cpus: 72, memory: 772.GB, time: 72.h ]
168176
}
177+
withLabel: "xfer" {
178+
queue = "xfer"
179+
resourceLimits = [ cpus: 1, memory: 4.GB, time: 48.h]
180+
}
169181

170182
/*
171183
* Runtime options
@@ -198,9 +210,6 @@ process {
198210
// executor.queueSize = 1
199211
container = "/projects/kumar-lab/multimouse-pipeline/rclone.sif"
200212
}
201-
withLabel: "dropbox" {
202-
DROPBOX_PREFIX = "labdropbox:KumarLab's shared workspace/VideoData/MDS_Tests"
203-
}
204213

205214
/*
206215
* Resource scaling labels

nextflow/modules/multi_mouse.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ process GENERATE_MULTI_MOUSE_TRACKLETS {
5858
val num_animals
5959

6060
output:
61-
tuple path(video_file), path("${video_file.baseName}_pose_est_v4.h5"), emit: pose_file
61+
tuple path(video_file), path("${video_file.baseName}_pose_est_v4.h5"), emit: files
6262

6363
// Number of tracklets is not yet a parameter accepted by code, so num_animals is currently ignored
6464
script:

0 commit comments

Comments
 (0)