From 8beef54d8d26cc8dbf0782200ef4ff902ded8e5e Mon Sep 17 00:00:00 2001 From: Rob Syme Date: Fri, 26 Jul 2024 18:06:29 -0400 Subject: [PATCH 1/3] More robust parsing of shm-size containerOptions This commit ensures that the `shm-size` option is correctly parsed from the containerOptions. This is necessary to ensure that the correct value in MiB is passed to the AWS Batch API when creating a job definition. Signed-off-by: Rob Syme --- .../nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/nf-amazon/src/main/nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy b/plugins/nf-amazon/src/main/nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy index 8a35732c33..d6bef978b2 100644 --- a/plugins/nf-amazon/src/main/nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy +++ b/plugins/nf-amazon/src/main/nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy @@ -22,6 +22,7 @@ import com.amazonaws.services.batch.model.Tmpfs import com.amazonaws.services.batch.model.Ulimit import groovy.transform.CompileStatic import nextflow.util.CmdLineOptionMap +import nextflow.util.MemoryUnit /** * Maps task container options to AWS container properties @@ -106,7 +107,8 @@ class AwsContainerOptionsMapper { // shared Memory Size def value = findOptionWithSingleValue(options, 'shm-size') if ( value ) { - params.setSharedMemorySize(value as Integer) + MemoryUnit sharedMemorySize = (value as MemoryUnit) + params.setSharedMemorySize(sharedMemorySize.mega as Integer) atLeastOneSet = true } From 4cbbd74bce307ce4b87aca4e6935b12b83ecebce Mon Sep 17 00:00:00 2001 From: Rob Syme Date: Fri, 26 Jul 2024 19:40:46 -0400 Subject: [PATCH 2/3] Add tests (and correct existing test) Signed-off-by: Rob Syme --- .../AwsContainerOptionsMapperTest.groovy | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/nf-amazon/src/test/nextflow/cloud/aws/batch/AwsContainerOptionsMapperTest.groovy b/plugins/nf-amazon/src/test/nextflow/cloud/aws/batch/AwsContainerOptionsMapperTest.groovy index 71315ed3e8..0ce1064a53 100644 --- a/plugins/nf-amazon/src/test/nextflow/cloud/aws/batch/AwsContainerOptionsMapperTest.groovy +++ b/plugins/nf-amazon/src/test/nextflow/cloud/aws/batch/AwsContainerOptionsMapperTest.groovy @@ -94,7 +94,25 @@ class AwsContainerOptionsMapperTest extends Specification { def map = CmdLineHelper.parseGnuArgs('--shm-size 12048024') def properties = AwsContainerOptionsMapper.createContainerProperties(map) then: - properties.getLinuxParameters().getSharedMemorySize() == 12048024 + properties.getLinuxParameters().getSharedMemorySize() == 11 + } + + def 'should set shared memory size with unit in MiB'() { + + when: + def map = CmdLineHelper.parseGnuArgs('--shm-size 256m') + def properties = AwsContainerOptionsMapper.createContainerProperties(map) + then: + properties.getLinuxParameters().getSharedMemorySize() == 256 + } + + def 'should set shared memory size with unit in GiB'() { + + when: + def map = CmdLineHelper.parseGnuArgs('--shm-size 1g') + def properties = AwsContainerOptionsMapper.createContainerProperties(map) + then: + properties.getLinuxParameters().getSharedMemorySize() == 1024 } def 'should set memory swappiness'() { From 548d40a79b63bf2e43e7632e4fab55d63174ca9c Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 27 Jul 2024 11:14:42 +0200 Subject: [PATCH 3/3] Minor change [ci fast] Signed-off-by: Paolo Di Tommaso --- .../nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nf-amazon/src/main/nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy b/plugins/nf-amazon/src/main/nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy index d6bef978b2..fc889d78fe 100644 --- a/plugins/nf-amazon/src/main/nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy +++ b/plugins/nf-amazon/src/main/nextflow/cloud/aws/batch/AwsContainerOptionsMapper.groovy @@ -107,7 +107,7 @@ class AwsContainerOptionsMapper { // shared Memory Size def value = findOptionWithSingleValue(options, 'shm-size') if ( value ) { - MemoryUnit sharedMemorySize = (value as MemoryUnit) + final sharedMemorySize = MemoryUnit.of(value) params.setSharedMemorySize(sharedMemorySize.mega as Integer) atLeastOneSet = true }