diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/FloatConf.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/FloatConf.groovy index 7159c64..d8be188 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/FloatConf.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/FloatConf.groovy @@ -40,6 +40,7 @@ class FloatConf { static final String NF_TASK_NAME = 'nextflow-io-task-name' static final String FLOAT_INPUT_SIZE = 'input-size' static final String FLOAT_JOB_KIND = 'job-kind' + static final long MIN_VOL_SIZE = 6 static final int DFT_MAX_CPU_FACTOR = 4 static final int DFT_MAX_MEM_FACTOR = 4 diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy index 7ccc0e2..3ef71f8 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy @@ -40,7 +40,6 @@ import java.nio.file.StandardCopyOption class FloatGridExecutor extends AbstractGridExecutor { private static final int DFT_MEM_GB = 1 private static final long FUSION_MIN_VOL_SIZE = 80 - private static final long MIN_VOL_SIZE = 40 private static final long DISK_INPUT_FACTOR = 5 private FloatJobs _floatJobs @@ -403,8 +402,8 @@ class FloatGridExecutor extends AbstractGridExecutor { return cmd } - private void addVolSize(List cmd, TaskRun task) { - long size = MIN_VOL_SIZE + void addVolSize(List cmd, TaskRun task) { + long size = FloatConf.MIN_VOL_SIZE def disk = task.config.getDisk() if (disk) { @@ -413,9 +412,11 @@ class FloatGridExecutor extends AbstractGridExecutor { if (isFusionEnabled()) { size = Math.max(size, FUSION_MIN_VOL_SIZE) } - long inputSizeGB = (long)(getInputFileSize(task) / 1024 / 1024 / 1024) - long minDiskSizeBasedOnInput = inputSizeGB * DISK_INPUT_FACTOR - size = Math.max(size, minDiskSizeBasedOnInput) + if (task.scratch) { + double inputSizeGB = (double)(getInputFileSize(task)) / 1024 / 1024 / 1024 + long minDiskSizeBasedOnInput = Math.round(inputSizeGB * DISK_INPUT_FACTOR) + size = Math.max(size, minDiskSizeBasedOnInput) + } cmd << '--imageVolSize' << size.toString() } diff --git a/plugins/nf-float/src/test/com/memverge/nextflow/FloatBaseTest.groovy b/plugins/nf-float/src/test/com/memverge/nextflow/FloatBaseTest.groovy index 200db36..cfc58a8 100644 --- a/plugins/nf-float/src/test/com/memverge/nextflow/FloatBaseTest.groovy +++ b/plugins/nf-float/src/test/com/memverge/nextflow/FloatBaseTest.groovy @@ -122,6 +122,6 @@ class FloatBaseTest extends BaseTest { '--customTag', "${FloatConf.NF_TASK_NAME}:foo--$taskIDStr-", '--customTag', "${FloatConf.FLOAT_INPUT_SIZE}:0", '--customTag', "${FloatConf.NF_RUN_NAME}:test-run", - '--imageVolSize', '40'] + '--imageVolSize', FloatConf.MIN_VOL_SIZE] } } diff --git a/plugins/nf-float/src/test/com/memverge/nextflow/FloatGridExecutorTest.groovy b/plugins/nf-float/src/test/com/memverge/nextflow/FloatGridExecutorTest.groovy index 6de3d9c..302d26c 100644 --- a/plugins/nf-float/src/test/com/memverge/nextflow/FloatGridExecutorTest.groovy +++ b/plugins/nf-float/src/test/com/memverge/nextflow/FloatGridExecutorTest.groovy @@ -78,7 +78,7 @@ class FloatGridExecutorTest extends FloatBaseTest { given: final exec = newTestExecutor() exec.floatJobs.updateJob(FloatJob.parse( - """ + """ id: a customTags: nf-job-id: tJob-1 @@ -211,7 +211,7 @@ class FloatGridExecutorTest extends FloatBaseTest { '10'] then: - cmd == expected + cmd.join(' ') == expected.join(' ') } def "add specific extras"() { @@ -421,10 +421,10 @@ class FloatGridExecutorTest extends FloatBaseTest { def "use time directive"() { given: final exec = newTestExecutor([ - float: [address: addr, - username: user, - password: pass, - nfs: nfs, + float: [address : addr, + username : user, + password : pass, + nfs : nfs, ignoreTimeFactor: false] ]) final task = newTask(exec, 0, new TaskConfig( @@ -442,12 +442,12 @@ class FloatGridExecutorTest extends FloatBaseTest { def "use timeout factor"() { given: final exec = newTestExecutor( - [float: [address : addr, - username : user, - password : pass, - nfs : nfs, + [float: [address : addr, + username : user, + password : pass, + nfs : nfs, ignoreTimeFactor: false, - timeFactor: 1.1]]) + timeFactor : 1.1]]) final task = newTask(exec, 0, new TaskConfig( container: image, time: '1h', @@ -629,7 +629,7 @@ class FloatGridExecutorTest extends FloatBaseTest { when: final count = taskMap.size() // update a list of the task status - for ( def entry : taskMap.entrySet()) { + for (def entry : taskMap.entrySet()) { exec.floatJobs.updateJob(FloatJob.parse(taskStatus(entry.key, entry.value))) } def res = exec.parseQueueStatus("") @@ -692,4 +692,43 @@ class FloatGridExecutorTest extends FloatBaseTest { setEnv('MMC_USERNAME') setEnv('MMC_PASSWORD') } + + def "get disk size when scratch is not enabled"() { + given: + final exec = newTestExecutor() + final task = newTask(exec, 0) + + when: + List cmd = [] + exec.addVolSize(cmd, task) + + then: + cmd.join(' ') == "--imageVolSize ${FloatConf.MIN_VOL_SIZE}" + } + + def "get disk size when specified in task"() { + given: + final exec = newTestExecutor() + final task = newTask(exec, 0, new TaskConfig(disk: '18.GB')) + + when: + List cmd = [] + exec.addVolSize(cmd, task) + + then: + cmd.join(' ') == "--imageVolSize 18" + } + + def "get disk size when specified size is smaller than min"() { + given: + final exec = newTestExecutor() + final task = newTask(exec, 0, new TaskConfig(disk: '2.GB')) + + when: + List cmd = [] + exec.addVolSize(cmd, task) + + then: + cmd.join(' ') == "--imageVolSize ${FloatConf.MIN_VOL_SIZE}" + } }