Skip to content

Commit

Permalink
Add support for selecting minimum CPU platform on GCP (#1633)
Browse files Browse the repository at this point in the history
Signed-off-by: hnawar <hnawar@google.com>
  • Loading branch information
hnawar committed Jun 22, 2020
1 parent ffc6f84 commit afc4375
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/google.rst
Expand Up @@ -106,6 +106,7 @@ google.region The Google *region* where the com
google.zone The Google *zone* where the computation is executed in Compute Engine VMs. Multiple zones can be provided separating them by a comma. Do not specify if a region is provided. See `available Compute Engine regions and zones <https://cloud.google.com/compute/docs/regions-zones/>`_
google.location The Google *location* where the job executions are deployed to Cloud Life Sciences API. See `available Cloud Life Sciences API locations <https://cloud.google.com/life-sciences/docs/concepts/locations>`_ (default: the same as the region or the zone specified).
google.enableRequesterPaysBuckets When ``true`` uses the configured Google project id as the billing project for storage access. This is required when accessing data from *reqester pays enabled* buckets. See `Requester Pays on Google Cloud Storage documentation <https://cloud.google.com/storage/docs/requester-pays>`_ (default: ``false``)
google.lifeSciences.cpuPlatform Set the minimum CPU Platform e.g `'Intel Skylake'` See `Specifying a minimum CPU Platform for VM instances <https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform#specifications>`_ (default: none).
google.lifeSciences.bootDiskSize Set the size of the virtual machine boot disk e.g `50.GB` (default: none).
google.lifeSciences.copyImage The container image run to copy input and output files. It must include the ``gsutil`` tool (default: ``google/cloud-sdk:alpine``).
google.lifeSciences.debug When ``true`` copies the `/google` debug directory in that task bucket directory (default: ``false``)
Expand Down
Expand Up @@ -52,6 +52,7 @@ class GoogleLifeSciencesConfig {
String location
boolean disableBinDir
MemoryUnit bootDiskSize
String cpuPlatform
boolean sshDaemon
String sshImage
Integer debugMode
Expand Down Expand Up @@ -109,6 +110,7 @@ class GoogleLifeSciencesConfig {
final boolean disableBinDir = config.navigate('google.lifeSciences.disableRemoteBinDir',false)
final preemptible = config.navigate("google.lifeSciences.preemptible", false) as boolean
final bootDiskSize = config.navigate('google.lifeSciences.bootDiskSize') as MemoryUnit
final cpuPlatform = config.navigate('google.lifeSciences.cpuPlatform') as String
final sshDaemon = config.navigate('google.lifeSciences.sshDaemon', false) as boolean
final sshImage = config.navigate('google.lifeSciences.sshImage', DEFAULT_SSH_IMAGE) as String
final copyImage = config.navigate('google.lifeSciences.copyImage', DEFAULT_COPY_IMAGE) as String
Expand All @@ -128,6 +130,7 @@ class GoogleLifeSciencesConfig {
preemptible: preemptible,
disableBinDir: disableBinDir,
bootDiskSize: bootDiskSize,
cpuPlatform: cpuPlatform,
debugMode: debugMode0(debugMode),
copyImage: copyImage,
sshDaemon: sshDaemon,
Expand Down
Expand Up @@ -190,6 +190,10 @@ class GoogleLifeSciencesHelper {
if( req.bootDiskSizeGb ) {
vm.setBootDiskSizeGb(req.bootDiskSizeGb)
}

if( req.cpuPlatform ) {
vm.setCpuPlatform(req.cpuPlatform)
}

if( req.accelerator ) {
final acc = new Accelerator().setType(req.accelerator.type).setCount(req.accelerator.request)
Expand Down
Expand Up @@ -59,6 +59,8 @@ class GoogleLifeSciencesSubmitRequest {
Path workDir

Integer bootDiskSizeGb

String cpuPlatform

String entryPoint

Expand Down
Expand Up @@ -299,6 +299,7 @@ class GoogleLifeSciencesTaskHandler extends TaskHandler {
req.sharedMount = configureMount(DEFAULT_DISK_NAME, task.workDir.toString())
req.accelerator = task.config.getAccelerator()
req.location = executor.config.location
req.cpuPlatform = executor.config.cpuPlatform
req.bootDiskSizeGb = executor.config.bootDiskSize?.toGiga() as Integer
req.entryPoint = task.config.getContainerOptionsMap().getOrDefault('entrypoint', GoogleLifeSciencesConfig.DEFAULT_ENTRY_POINT)
req.usePrivateAddress = executor.config.usePrivateAddress
Expand Down
Expand Up @@ -240,5 +240,18 @@ class GoogleLifeSciencesConfigTest extends Specification {
config.enableRequesterPaysBuckets == true

}

def 'should config cpuPlatform' () {
when:
def config = GoogleLifeSciencesConfig.fromSession0([google:[project:'foo', region:'x', lifeSciences: [:]]])
then:
config.cpuPlatform == null

when:
config = GoogleLifeSciencesConfig.fromSession0([google:[project:'foo', region:'x', lifeSciences: [cpuPlatform:'Intel Skylake']]])
then:
config.cpuPlatform == 'Intel Skylake'

}

}
Expand Up @@ -189,6 +189,7 @@ class GoogleLifeSciencesHelperTest extends GoogleSpecification {
preemptible: false,
accelerator: acc,
bootDiskSizeGb: 75,
cpuPlatform: 'Intel Skylake',
usePrivateAddress: true ))
then:
with(resources3) {
Expand All @@ -202,6 +203,7 @@ class GoogleLifeSciencesHelperTest extends GoogleSpecification {
getVirtualMachine().getAccelerators()[0].getCount()==4
getVirtualMachine().getAccelerators()[0].getType()=='nvidia-tesla-k80'
getVirtualMachine().getBootDiskSizeGb() == 75
getVirtualMachine().getCpuPlatform() == 'Intel Skylake'
getVirtualMachine().getNetwork().getUsePrivateAddress()
}
}
Expand Down
Expand Up @@ -178,6 +178,7 @@ class GoogleLifeSciencesTaskHandlerTest extends GoogleSpecification {
req.sharedMount.getDisk() == GoogleLifeSciencesTaskHandler.DEFAULT_DISK_NAME
!req.sharedMount.getReadOnly()
req.bootDiskSizeGb == null
req.cpuPlatform == null
req.entryPoint == GoogleLifeSciencesConfig.DEFAULT_ENTRY_POINT
!req.usePrivateAddress

Expand Down Expand Up @@ -211,6 +212,7 @@ class GoogleLifeSciencesTaskHandlerTest extends GoogleSpecification {
getPreemptible() >> true
getBootDiskSize() >> MemoryUnit.of('20 GB')
getUsePrivateAddress() >> true
getCpuPlatform() >> 'Intel Skylake'
}
}
}
Expand Down Expand Up @@ -244,6 +246,7 @@ class GoogleLifeSciencesTaskHandlerTest extends GoogleSpecification {
req.sharedMount.getDisk() == GoogleLifeSciencesTaskHandler.DEFAULT_DISK_NAME
!req.sharedMount.getReadOnly()
req.bootDiskSizeGb == 20
req.cpuPlatform =='Intel Skylake'
req.entryPoint == GoogleLifeSciencesConfig.DEFAULT_ENTRY_POINT
req.usePrivateAddress

Expand Down

0 comments on commit afc4375

Please sign in to comment.