Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
THWiseman committed Nov 8, 2023
1 parent ca61172 commit f7a0e20
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ object PredefinedMachineType {
val c3Standard_176 = PredefinedMachineType(176, "c3-standard-176")

Check warning on line 17 in supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala#L12-L17

Added lines #L12 - L17 were not covered by tests

def getClosestC3Machine(requestedMemory: MemorySize, requestedCpu: Refined[Int, Positive], jobLogger: Logger): String = {
val c3DebugString = "Intel Sapphire Rapids C3 machine type"

Check warning on line 20 in supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala#L20

Added line #L20 was not covered by tests

// Memory isn't configurable for c3 machines: it's always 4x the CPU count. Adjust memory to match requested CPU count.
val adjustedMemory: MemorySize = MemorySize(requestedCpu.value * 4.0, MemoryUnit.GB)
if (adjustedMemory != requestedMemory) {
jobLogger.info(s"Adjusting memory from ${requestedMemory.toString} to ${adjustedMemory.toString} in order to match GCP requirements for the requested CPU.")
jobLogger.info(s"Adjusting memory from ${requestedMemory.toString} to ${adjustedMemory.toString} in order to match GCP requirements for the requested ${c3DebugString}.")

Check warning on line 25 in supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala#L23-L25

Added lines #L23 - L25 were not covered by tests
}

// Always round up requested CPU to next smallest size.
val machine = requestedCpu.value match {
case cpu if cpu <= 4 => c3Standard_4
case cpu if cpu > 4 && cpu <= 8 => c3Standard_8
Expand All @@ -31,7 +36,7 @@ object PredefinedMachineType {
}

if(machine.cpuCount != requestedCpu.value) {
jobLogger.info(s"Rounding up CPU count from ${requestedCpu} to ${machine.cpuCount} in order to match GCP requirements for the requested CPU.")
jobLogger.info(s"Rounding up CPU count from ${requestedCpu} to ${machine.cpuCount} in order to match GCP requirements for the requested ${c3DebugString}.")

Check warning on line 39 in supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala#L38-L39

Added lines #L38 - L39 were not covered by tests
}
machine.gcpString

Check warning on line 41 in supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/google/pipelines/common/src/main/scala/cromwell/backend/google/pipelines/common/PredefinedMachineType.scala#L41

Added line #L41 was not covered by tests
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ import wom.format.MemorySize
class MachineConstraintsSpec extends AnyFlatSpec with CromwellTimeoutSpec with Matchers {
behavior of "MachineConstraints"

private val n2Option = Option(PipelinesApiRuntimeAttributes.CpuPlatformIntelCascadeLakeValue)
private val n2OptionCascade = Option(PipelinesApiRuntimeAttributes.CpuPlatformIntelCascadeLakeValue)

private val n2dOption = Option(PipelinesApiRuntimeAttributes.CpuPlatformAMDRomeValue)
private val n2dOption = Option(PipelinesApiRuntimeAttributes.CpuPlatformAMDRomeValue)

private val n2OptionIceLake = Option(PipelinesApiRuntimeAttributes.CpuPlatformIntelIceLakeValue)

private val c3OptionSapphireRapids = Option(PipelinesApiRuntimeAttributes.CpuPlatformIntelSapphireRapidsValue)

it should "generate valid machine types" in {
val validTypes = Table(
Expand All @@ -40,7 +44,6 @@ class MachineConstraintsSpec extends AnyFlatSpec with CromwellTimeoutSpec with M

// Same tests as above but with legacy machine type selection (cpu and memory as specified. No 'custom machine
// requirement' adjustments are expected this time, except float->int)

(MemorySize(1024, MemoryUnit.MB), refineMV[Positive](1), None, true, "predefined-1-1024"),
(MemorySize(4, MemoryUnit.GB), refineMV[Positive](3), None, true, "predefined-3-4096"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](1), None, true, "predefined-1-1024"),
Expand All @@ -52,15 +55,26 @@ class MachineConstraintsSpec extends AnyFlatSpec with CromwellTimeoutSpec with M
(MemorySize(2, MemoryUnit.GB), refineMV[Positive](33), None, true, "predefined-33-2048"),

// Same tests but with cascade lake (n2)
(MemorySize(1024, MemoryUnit.MB), refineMV[Positive](1), n2Option, false, "n2-custom-2-2048"),
(MemorySize(4, MemoryUnit.GB), refineMV[Positive](3), n2Option, false, "n2-custom-4-4096"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](1), n2Option, false, "n2-custom-2-2048"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](4), n2Option, false, "n2-custom-4-4096"),
(MemorySize(14, MemoryUnit.GB), refineMV[Positive](16), n2Option, false, "n2-custom-16-16384"),
(MemorySize(13.65, MemoryUnit.GB), refineMV[Positive](1), n2Option, false, "n2-custom-2-14080"),
(MemorySize(1520.96, MemoryUnit.MB), refineMV[Positive](1), n2Option, false, "n2-custom-2-2048"),
(MemorySize(1024.0, MemoryUnit.MB), refineMV[Positive](1), n2Option, false, "n2-custom-2-2048"),
(MemorySize(2, MemoryUnit.GB), refineMV[Positive](33), n2Option, false, "n2-custom-36-36864"),
(MemorySize(1024, MemoryUnit.MB), refineMV[Positive](1), n2OptionCascade, false, "n2-custom-2-2048"),
(MemorySize(4, MemoryUnit.GB), refineMV[Positive](3), n2OptionCascade, false, "n2-custom-4-4096"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](1), n2OptionCascade, false, "n2-custom-2-2048"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](4), n2OptionCascade, false, "n2-custom-4-4096"),
(MemorySize(14, MemoryUnit.GB), refineMV[Positive](16), n2OptionCascade, false, "n2-custom-16-16384"),
(MemorySize(13.65, MemoryUnit.GB), refineMV[Positive](1), n2OptionCascade, false, "n2-custom-2-14080"),
(MemorySize(1520.96, MemoryUnit.MB), refineMV[Positive](1), n2OptionCascade, false, "n2-custom-2-2048"),
(MemorySize(1024.0, MemoryUnit.MB), refineMV[Positive](1), n2OptionCascade, false, "n2-custom-2-2048"),
(MemorySize(2, MemoryUnit.GB), refineMV[Positive](33), n2OptionCascade, false, "n2-custom-36-36864"),

// Same tests, but with ice lake. Should produce same results as cascade lake since they're both n2.
(MemorySize(1024, MemoryUnit.MB), refineMV[Positive](1), n2OptionIceLake, false, "n2-custom-2-2048"),
(MemorySize(4, MemoryUnit.GB), refineMV[Positive](3), n2OptionIceLake, false, "n2-custom-4-4096"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](1), n2OptionIceLake, false, "n2-custom-2-2048"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](4), n2OptionIceLake, false, "n2-custom-4-4096"),
(MemorySize(14, MemoryUnit.GB), refineMV[Positive](16), n2OptionIceLake, false, "n2-custom-16-16384"),
(MemorySize(13.65, MemoryUnit.GB), refineMV[Positive](1), n2OptionIceLake, false, "n2-custom-2-14080"),
(MemorySize(1520.96, MemoryUnit.MB), refineMV[Positive](1), n2OptionIceLake, false, "n2-custom-2-2048"),
(MemorySize(1024.0, MemoryUnit.MB), refineMV[Positive](1), n2OptionIceLake, false, "n2-custom-2-2048"),
(MemorySize(2, MemoryUnit.GB), refineMV[Positive](33), n2OptionIceLake, false, "n2-custom-36-36864"),

// Same tests but with AMD Rome (n2d) #cpu > 16 are in increments of 16
(MemorySize(1024, MemoryUnit.MB), refineMV[Positive](1), n2dOption, false, "n2d-custom-2-1024"),
Expand All @@ -73,7 +87,24 @@ class MachineConstraintsSpec extends AnyFlatSpec with CromwellTimeoutSpec with M
(MemorySize(1024.0, MemoryUnit.MB), refineMV[Positive](1), n2dOption, false, "n2d-custom-2-1024"),
(MemorySize(2, MemoryUnit.GB), refineMV[Positive](33), n2dOption, false, "n2d-custom-48-24576"),
(MemorySize(2, MemoryUnit.GB), refineMV[Positive](81), n2dOption, false, "n2d-custom-96-49152"),
(MemorySize(256, MemoryUnit.GB), refineMV[Positive](128), n2dOption, false, "n2d-custom-96-262144")
(MemorySize(256, MemoryUnit.GB), refineMV[Positive](128), n2dOption, false, "n2d-custom-96-262144"),

// Sapphire Rapids (c3). Unlike the above, this machine isn't customizable, so we expect one of six options.
// MemorySize is ignored since it must always be a multiple of the CPU count for c3 machines.
(MemorySize(1, MemoryUnit.MB), refineMV[Positive](1), c3OptionSapphireRapids, false, "c3-standard-4"),
(MemorySize(10, MemoryUnit.GB), refineMV[Positive](1), c3OptionSapphireRapids, false, "c3-standard-4"),
(MemorySize(100, MemoryUnit.TB), refineMV[Positive](1), c3OptionSapphireRapids, false, "c3-standard-4"),
(MemorySize(1, MemoryUnit.MB), refineMV[Positive](2), c3OptionSapphireRapids, false, "c3-standard-4"),
(MemorySize(10, MemoryUnit.GB), refineMV[Positive](3), c3OptionSapphireRapids, false, "c3-standard-4"),
(MemorySize(100, MemoryUnit.TB), refineMV[Positive](4), c3OptionSapphireRapids, false, "c3-standard-4"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](5), c3OptionSapphireRapids, false, "c3-standard-8"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](21), c3OptionSapphireRapids, false, "c3-standard-22"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](22), c3OptionSapphireRapids, false, "c3-standard-22"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](23), c3OptionSapphireRapids, false, "c3-standard-44"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](50), c3OptionSapphireRapids, false, "c3-standard-88"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](100), c3OptionSapphireRapids, false, "c3-standard-176"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](200), c3OptionSapphireRapids, false, "c3-standard-176"),
(MemorySize(1, MemoryUnit.GB), refineMV[Positive](300), c3OptionSapphireRapids, false, "c3-standard-176"),
)

forAll(validTypes) { (memory, cpu, cpuPlatformOption, googleLegacyMachineSelection, expected) =>
Expand Down

0 comments on commit f7a0e20

Please sign in to comment.