Skip to content

Commit 00f35b3

Browse files
jorgeebentsherman
andauthored
Add accelerator request to trace record (#6703)
Co-authored-by: Ben Sherman <bentshermann@gmail.com>
1 parent e3bf315 commit 00f35b3

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

modules/nextflow/src/main/groovy/nextflow/processor/TaskHandler.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ abstract class TaskHandler {
221221
record.env = task.getEnvironmentStr()
222222
record.executorName = task.processor.executor.getName()
223223
record.containerMeta = task.containerMeta()
224+
record.accelerator = task.config.getAccelerator()?.request
225+
record.accelerator_type = task.config.getAccelerator()?.type
224226

225227
if( isCompleted() ) {
226228
record.error_action = task.errorAction?.toString()

modules/nextflow/src/main/groovy/nextflow/trace/TraceRecord.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ class TraceRecord implements Serializable {
103103
vol_ctxt: 'num', // -- /proc/$pid/status field 'voluntary_ctxt_switches'
104104
inv_ctxt: 'num', // -- /proc/$pid/status field 'nonvoluntary_ctxt_switches'
105105
hostname: 'str',
106-
cpu_model: 'str'
106+
cpu_model: 'str',
107+
accelerator: 'num',
108+
accelerator_type: 'str'
107109
]
108110

109111
static public Map<String,Closure<String>> FORMATTER = [

modules/nextflow/src/test/groovy/nextflow/processor/TaskHandlerTest.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class TaskHandlerTest extends Specification {
5252
cpus: 2,
5353
time: '1 hour',
5454
disk: '100 GB',
55-
memory: '4 GB'
55+
memory: '4 GB',
56+
accelerator: [request: 3, type: 'v100']
5657
]
5758
def task = new TaskRun(id: new TaskId(100), workDir: folder, name:'task1', exitStatus: 127, config: config )
5859
task.metaClass.getHashLog = { "5d5d7ds" }
@@ -100,6 +101,8 @@ class TaskHandlerTest extends Specification {
100101
trace.memory == MemoryUnit.of('4 GB').toBytes()
101102
trace.disk == MemoryUnit.of('100 GB').toBytes()
102103
trace.env == 'FOO=hola\nBAR=mundo\nAWS_SECRET=[secure]\n'
104+
trace.accelerator == 3
105+
trace.accelerator_type == 'v100'
103106

104107
// check get method
105108
trace.getFmtStr('%cpu') == '1.0%'

modules/nextflow/src/test/groovy/nextflow/trace/TraceRecordTest.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ class TraceRecordTest extends Specification {
246246
record.cpus = 4
247247
record.time = 3_600_000L
248248
record.memory = 1024L * 1024L * 1024L * 8L
249+
record.accelerator = 3
250+
record.accelerator_type = 'v100'
249251

250252
when:
251253
def json = new JsonSlurper().parseText(record.renderJson().toString())
@@ -261,6 +263,8 @@ class TraceRecordTest extends Specification {
261263
json.cpus == '4'
262264
json.time == '1h'
263265
json.memory == '8 GB'
266+
json.accelerator == '3'
267+
json.accelerator_type == 'v100'
264268

265269
}
266270

plugins/nf-tower/src/test/io/seqera/tower/plugin/TowerClientTest.groovy

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,4 +560,31 @@ class TowerClientTest extends Specification {
560560
req.tasks[0].numSpotInterruptions == 3
561561
}
562562

563+
def 'should include accelerator request in task map'() {
564+
given:
565+
def client = Spy(new TowerClient())
566+
client.getWorkflowProgress(true) >> new WorkflowProgress()
567+
568+
def now = System.currentTimeMillis()
569+
def trace = new TraceRecord([
570+
taskId: 42,
571+
process: 'foo',
572+
workdir: "/work/dir",
573+
cpus: 1,
574+
submit: now-2000,
575+
start: now-1000,
576+
complete: now,
577+
accelerator: 2,
578+
acceleratorType: 'v100'
579+
])
580+
581+
when:
582+
def req = client.makeTasksReq([trace])
583+
584+
then:
585+
req.tasks.size() == 1
586+
req.tasks[0].accelerator == 2
587+
req.tasks[0].acceleratorType == 'v100'
588+
}
589+
563590
}

0 commit comments

Comments
 (0)