From 96db2e70a2468029f67484626d2b27cff7b9cdaf Mon Sep 17 00:00:00 2001 From: Till Englert Date: Thu, 10 Oct 2024 05:15:50 +0200 Subject: [PATCH] Cast `memory` later, so the calculation to GB is performed using the full precision data. Also add a comment, why it is casted and add TODO Signed-off-by: Till Englert --- .../main/nextflow/co2footprint/CO2FootprintFactory.groovy | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy index fd4efb3..444180e 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy @@ -182,7 +182,7 @@ class CO2FootprintFactory implements TraceObserverFactory { * Factors of memory power usage */ // nm: size of memory available [GB] -> requested memory - Double memory = trace.get('memory') as Double + Long memory = trace.get('memory') as Long if ( memory == null ) { // TODO if 'memory' not set, returns null, hande somehow? log.error "TraceRecord field 'memory' is not set!" @@ -216,7 +216,11 @@ class CO2FootprintFactory implements TraceObserverFactory { e = e * 1000000 c = c * 1000 - return [e, c, realtime, nc, pc, uc, memory] + // TODO: Only a workaround. Like this the memory is only full precision until 999TB of GB. + // The cast is still necessary, as the output expects a List which worked with Groovy3 but not Groovy4 + Double mem_double = memory as Double + + return [e, c, realtime, nc, pc, uc, mem_double] }