Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust parsing of shm-size containerOptions #5177

Merged
merged 3 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -106,7 +107,8 @@ class AwsContainerOptionsMapper {
// shared Memory Size
def value = findOptionWithSingleValue(options, 'shm-size')
if ( value ) {
params.setSharedMemorySize(value as Integer)
final sharedMemorySize = MemoryUnit.of(value)
params.setSharedMemorySize(sharedMemorySize.mega as Integer)
atLeastOneSet = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
pditommaso marked this conversation as resolved.
Show resolved Hide resolved
}

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'() {
Expand Down