uclahs-cds / pipeline-recalibrate-BAM

Nextflow pipeline to perform Indel Realignment and Base Quality Score Recalibration
https://uclahs-cds.github.io/pipeline-recalibrate-BAM/
GNU General Public License v2.0
1 stars 1 forks source link

Remove local set_env and check_limits methods #46

Closed nwiltsie closed 11 months ago

nwiltsie commented 11 months ago

Description

This just removes the local copies of methods.set_env and methods.check_limits in favor of the updated versions from the submodule.

Unfortunately there's not a great way to show that the code blocks are equivalent other than by pasting diffs in here (I stripped a few comments):

--- local_check.config  2023-12-20 15:50:02.115400000 -0800
+++ submodule_check.config  2023-12-20 15:50:01.447858000 -0800
@@ -1,4 +1,4 @@
-    check_limits = { obj, type ->
+    check_limits = { Object obj, String type ->
         if (type == 'memory') {
             try {
                 if (obj.compareTo(params.max_memory as nextflow.util.MemoryUnit) == 1)
@@ -8,7 +8,7 @@
                 else
                     return obj
             } catch (all) {
-                println "   ### WARNING ###   Max memory '${params.max_memory}' or min memory '${params.min_memory}' is not valid! Using default value: $obj"
+                System.out.println("   ### WARNING ###   Max memory '${params.max_memory}' or min memory '${params.min_memory}' is not valid! Using default value: $obj")
                 return obj
             }
         } else if (type == 'time') {
@@ -20,14 +20,14 @@
                 else
                     return obj
             } catch (all) {
-                println "   ### WARNING ###   Max time '${params.max_time}' or min time '${params.min_time}' is not valid! Using default value: $obj"
+                System.out.println("   ### WARNING ###   Max time '${params.max_time}' or min time '${params.min_time}' is not valid! Using default value: $obj")
                 return obj
             }
         } else if (type == 'cpus') {
             try {
-                return Math.max( Math.min( obj, params.max_cpus as int ), params.min_cpus as int )
+                return Math.max( Math.min( obj as int, params.max_cpus as int ), params.min_cpus as int )
             } catch (all) {
-                println "   ### WARNING ###   Max cpus '${params.max_cpus}' or min cpus '${params.min_cpus}' is not valid! Using default value: $obj"
+                System.out.println("   ### WARNING ###   Max cpus '${params.max_cpus}' or min cpus '${params.min_cpus}' is not valid! Using default value: $obj")
                 return obj
             }
         }
--- local_set_env.config    2023-12-20 15:52:05.911211000 -0800
+++ submodule_set_env.config    2023-12-20 15:52:06.585748000 -0800
@@ -1,13 +1,17 @@
     set_env = {
         if (params.ucla_cds) {
-            params.work_dir = (params.containsKey('work_dir') && params.work_dir) ? params.work_dir : '/scratch'
-            if (methods.check_workdir_permissions(params.work_dir)) {
-                workDir = params.work_dir
-            }
+            params.work_dir = (params.containsKey('work_dir') && params.work_dir) ? params.work_dir : methods.get_default_workdir()
+            schema.check_path(params.work_dir, 'w')
+            workDir = params.work_dir
         } else {
             // If work_dir was specified as a param and exists or can be created, set workDir. Otherwise, let Nextflow's default behavior dictate workDir
-            if (params.containsKey('work_dir') && params.work_dir && methods.check_workdir_permissions(params.work_dir)) {
+            // Default Nextflow behavior: NXF_WORK environment variable if set, otherwise "${launchDir}/work"
+            if (params.containsKey("work_dir") && params.work_dir) {
+                schema.check_path(params.work_dir, 'w')
                 workDir = params.work_dir
+            } else {
+                // Set the work_dir to match the default Nextflow behavior for parity
+                params.work_dir = System.getenv("NXF_WORK") ?: "${launchDir}/work"
             }
         }
     }

Testing Results

Checklist

yashpatel6 commented 11 months ago

@nwiltsie I ended up removing the local set_env in #45 so the branch here will need to be updated to resolve the conflicts

nwiltsie commented 11 months ago

@yashpatel6 You monster. Changes merged, I'm re-running NFTest for sanity now and I'll report back once that passes.

nwiltsie commented 11 months ago

Confirmed, be57078 (after merging the changes from #45) still passes NFTest: /hot/software/pipeline/pipeline-recalibrate-BAM/Nextflow/development/unreleased/nwiltsie_fix_scratch/log-nftest-20231221T185448Z.log