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

WX-1810 WX-1830 n1/n2/n2d machine types, cpuPlatform on GCPBATCH #7518

Merged
merged 8 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ be found [here](https://cromwell.readthedocs.io/en/stable/backends/HPC/#optional

- The `genomics` configuration entry was renamed to `batch`, see [ReadTheDocs](https://cromwell.readthedocs.io/en/stable/backends/GCPBatch/) for more information.
- Fixes a bug with not being able to recover jobs on Cromwell restart.
- Fixes machine type selection to match the Google Cloud Life Sciences backend, including default n1 non shared-core machine types and correct handling of `cpuPlatform` to select n2 or n2d machine types as appropriate.
- Fixes the preemption error handling, now, the correct error message is printed, this also handles the other potential exit codes.
- Fixes error message reporting for failed jobs.
- Fixes the "retry with more memory" feature.
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ lazy val googlePipelinesV2Beta = (project in backendRoot / "google" / "pipelines

lazy val googleBatch = (project in backendRoot / "google" / "batch")
.withLibrarySettings("cromwell-google-batch-backend")
.dependsOn(core)
.dependsOn(backend)
.dependsOn(gcsFileSystem)
.dependsOn(drsFileSystem)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: papi_cpu_platform
testFormat: workflowsuccess
backends: [Papiv2]
backendsMode: any
backends: [Papiv2, GCPBATCH]

files {
workflow: papi_cpu_platform/papi_cpu_platform.wdl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
backendSingletonActor ! BatchApiRequestManager.BatchRunCreationRequest(
request.workflowId,
self,
requestFactory.submitRequest(request)
requestFactory.submitRequest(request, jobLogger)

Check warning on line 56 in supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/actors/BatchApiRunCreationClient.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/actors/BatchApiRunCreationClient.scala#L56

Added line #L56 was not covered by tests
)
val newPromise = Promise[StandardAsyncJob]()
runCreationClientPromise = Option(newPromise)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import cromwell.backend.google.batch.io.GcpBatchAttachedDisk
import cromwell.backend.google.batch.models.GcpBatchConfigurationAttributes.VirtualPrivateCloudConfiguration
import cromwell.backend.google.batch.models._
import cromwell.backend.google.batch.monitoring.{CheckpointingConfiguration, MonitoringImage}
import cromwell.core.logging.JobLogger
import cromwell.core.path.Path
import wom.runtime.WomOutputRuntimeExtractor

import scala.concurrent.duration.FiniteDuration

trait GcpBatchRequestFactory {
def submitRequest(data: GcpBatchRequest): CreateJobRequest
def submitRequest(data: GcpBatchRequest, jobLogger: JobLogger): CreateJobRequest

def queryRequest(jobName: JobName): GetJobRequest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import cromwell.backend.google.batch.models.GcpBatchConfigurationAttributes.GcsTransferConfiguration
import cromwell.backend.google.batch.models.{GcpBatchRequest, VpcAndSubnetworkProjectLabelValues}
import cromwell.backend.google.batch.runnable._
import cromwell.backend.google.batch.util.BatchUtilityConversions
import cromwell.backend.google.batch.util.{BatchUtilityConversions, GcpBatchMachineConstraints}
import cromwell.core.logging.JobLogger

import scala.jdk.CollectionConverters._

Expand Down Expand Up @@ -74,14 +75,16 @@
private def createInstancePolicy(cpuPlatform: String,
spotModel: ProvisioningModel,
accelerators: Option[Accelerator.Builder],
attachedDisks: List[AttachedDisk]
attachedDisks: List[AttachedDisk],
machineType: String
): InstancePolicy.Builder = {

// set GPU count to 0 if not included in workflow
val gpuAccelerators = accelerators.getOrElse(Accelerator.newBuilder.setCount(0).setType("")) // TODO: Driver version

val instancePolicy = InstancePolicy.newBuilder
.setProvisioningModel(spotModel)
.setMachineType(machineType)
.addAllDisks(attachedDisks.asJava)
.setMinCpuPlatform(cpuPlatform)
.buildPartial()
Expand Down Expand Up @@ -154,7 +157,7 @@
}
}

override def submitRequest(data: GcpBatchRequest): CreateJobRequest = {
override def submitRequest(data: GcpBatchRequest, jobLogger: JobLogger): CreateJobRequest = {

val runtimeAttributes = data.gcpBatchParameters.runtimeAttributes
val createParameters = data.createParameters
Expand Down Expand Up @@ -224,7 +227,13 @@
val computeResource = createComputeResource(cpuCores, memory, gcpBootDiskSizeMb)
val taskSpec = createTaskSpec(sortedRunnables, computeResource, retryCount, durationInSeconds, allVolumes)
val taskGroup: TaskGroup = createTaskGroup(taskCount, taskSpec)
val instancePolicy = createInstancePolicy(cpuPlatform, spotModel, accelerators, allDisks)
val machineType = GcpBatchMachineConstraints.machineType(runtimeAttributes.memory,
runtimeAttributes.cpu,
cpuPlatformOption = runtimeAttributes.cpuPlatform,
googleLegacyMachineSelection = false,

Check warning on line 233 in supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/api/GcpBatchRequestFactoryImpl.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/api/GcpBatchRequestFactoryImpl.scala#L230-L233

Added lines #L230 - L233 were not covered by tests
jobLogger = jobLogger
)
val instancePolicy = createInstancePolicy(cpuPlatform, spotModel, accelerators, allDisks, machineType)

Check warning on line 236 in supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/api/GcpBatchRequestFactoryImpl.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/api/GcpBatchRequestFactoryImpl.scala#L236

Added line #L236 was not covered by tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using named arguments to avoid confusing cpuPlatform/machineType because both are strings.

val locationPolicy = LocationPolicy.newBuilder.addAllowedLocations(zones).build
val allocationPolicy =
createAllocationPolicy(data, locationPolicy, instancePolicy.build, networkPolicy, gcpSa, accelerators)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
private val cpuPlatformValidationInstance = new StringRuntimeAttributesValidation(CpuPlatformKey).optional
// via `gcloud compute zones describe us-central1-a`
val CpuPlatformIntelCascadeLakeValue = "Intel Cascade Lake"
val CpuPlatformIntelIceLakeValue = "Intel Ice Lake"

Check warning on line 80 in supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/models/GcpBatchRuntimeAttributes.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/models/GcpBatchRuntimeAttributes.scala#L80

Added line #L80 was not covered by tests
val CpuPlatformAMDRomeValue = "AMD Rome"

val UseDockerImageCacheKey = "useDockerImageCache"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
N2CustomMachineType,
N2DCustomMachineType
}
import cromwell.core.logging.JobLogger
import eu.timepit.refined.api.Refined
import eu.timepit.refined.numeric.Positive
import org.slf4j.Logger
import wdl4s.parser.MemoryUnit
import wom.format.MemorySize

Expand All @@ -17,16 +17,17 @@
cpu: Int Refined Positive,
cpuPlatformOption: Option[String],
googleLegacyMachineSelection: Boolean,
jobLogger: Logger
jobLogger: JobLogger
): String =
if (googleLegacyMachineSelection) {
s"predefined-$cpu-${memory.to(MemoryUnit.MB).amount.intValue()}"
} else {
// If someone requests Intel Cascade Lake as their CPU platform then switch the machine type to n2.
// If someone requests Intel Cascade Lake or Intel Ice Lake as their CPU platform then switch the machine type to n2.
// Similarly, CPU platform of AMD Rome corresponds to the machine type n2d.
val customMachineType =
cpuPlatformOption match {
case Some(GcpBatchRuntimeAttributes.CpuPlatformIntelCascadeLakeValue) => N2CustomMachineType
case Some(GcpBatchRuntimeAttributes.CpuPlatformIntelIceLakeValue) => N2CustomMachineType

Check warning on line 30 in supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/util/GcpBatchMachineConstraints.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/batch/src/main/scala/cromwell/backend/google/batch/util/GcpBatchMachineConstraints.scala#L30

Added line #L30 was not covered by tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can cover this with tests at GcpBatchMachineConstraintsSpec

case Some(GcpBatchRuntimeAttributes.CpuPlatformAMDRomeValue) => N2DCustomMachineType
case _ => N1CustomMachineType
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class GcpBatchAsyncBackendJobExecutionActorSpec
val runtimeAttributesBuilder = GcpBatchRuntimeAttributes.runtimeAttributesBuilder(configuration)

val requestFactory: GcpBatchRequestFactory = new GcpBatchRequestFactory {
override def submitRequest(data: GcpBatchRequest): CreateJobRequest = null
override def submitRequest(data: GcpBatchRequest, jobLogger: JobLogger): CreateJobRequest = null

override def queryRequest(jobName: JobName): GetJobRequest = null

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package cromwell.backend.google.batch.util

import common.assertion.CromwellTimeoutSpec
import common.mock.MockSugar.mock
import cromwell.backend.google.batch.models.GcpBatchRuntimeAttributes
import cromwell.core.logging.JobLogger
import eu.timepit.refined.numeric.Positive
import eu.timepit.refined.refineMV
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalatest.prop.TableDrivenPropertyChecks._
import org.scalatest.prop.Tables.Table
import org.slf4j.helpers.NOPLogger
import wdl4s.parser.MemoryUnit
import wom.format.MemorySize

Expand Down Expand Up @@ -83,7 +84,7 @@ class GcpBatchMachineConstraintsSpec extends AnyFlatSpec with CromwellTimeoutSpe
cpu = cpu,
cpuPlatformOption = cpuPlatformOption,
googleLegacyMachineSelection = googleLegacyMachineSelection,
jobLogger = NOPLogger.NOP_LOGGER
jobLogger = mock[JobLogger]
) shouldBe expected
}
}
Expand Down
Loading