diff --git a/docs/usage/parameters.md b/docs/usage/parameters.md index 782ee6f..5edd3e1 100644 --- a/docs/usage/parameters.md +++ b/docs/usage/parameters.md @@ -11,7 +11,7 @@ You can adjust the nf-co2footprint plugin parameters in your config file as foll def co2_timestamp = new java.util.Date().format( 'yyyy-MM-dd_HH-mm-ss') co2footprint { - file = "${params.outdir}/co2footprint_trace_${co2_timestamp}.txt" + traceFile = "${params.outdir}/co2footprint_trace_${co2_timestamp}.txt" reportFile = "${params.outdir}/co2footprint_report_${co2_timestamp}.html" ci = 300 pue = 1.4 @@ -26,7 +26,7 @@ nextflow run nextflow-io/hello -c nextflow.config The following parameters are currently available: -- `file`: Name of the TXT carbon footprint report containing the energy consumption, the estimated CO2 emission and other relevant metrics for each task. +- `traceFile`: Name of the TXT carbon footprint report containing the energy consumption, the estimated CO2 emission and other relevant metrics for each task. Default: `co2footprint_trace_.txt`. - `summaryFile`: Name of the TXT carbon footprint summary file containing the total energy consumption and the total estimated CO2 emission of the pipeline run. Default: `co2footprint_summary_.txt`. diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintConfig.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintConfig.groovy index 7d1387a..f4d79aa 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintConfig.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintConfig.groovy @@ -6,10 +6,10 @@ import groovy.util.logging.Slf4j /** * This class allows model an specific configuration, extracting values from a map and converting * - * In this plugin, the user can configure the output file names of the CO2 footprint calculations + * In this plugin, the user can configure the output traceFile names of the CO2 footprint calculations * * co2footprint { - * file = "co2footprint_trace.txt" + * traceFile = "co2footprint_trace.txt" * summaryFile = "co2footprint_summary.txt" * ci = 300 * pue = 1.4 @@ -27,7 +27,7 @@ import groovy.util.logging.Slf4j @PackageScope class CO2FootprintConfig { - final private String file + final private String traceFile final private String summaryFile final private String reportFile final private String location @@ -37,7 +37,7 @@ class CO2FootprintConfig { final private Boolean ignoreCpuModel final private Double powerdrawCpuDefault - // Retrieve CI value from file containing CI values for different locations + // Retrieve CI value from traceFile containing CI values for different locations protected Double retrieveCi(String location) { def dataReader = new InputStreamReader(this.class.getResourceAsStream('/CI_aggregated.v2.2.csv')) @@ -57,7 +57,7 @@ class CO2FootprintConfig { return localCi } - // Load user provided file containing custom TDP values for different CPU models + // Load user provided traceFile containing custom TDP values for different CPU models protected void loadCustomCpuTdpData(Map data, String customCpuTdpFile) { new File(customCpuTdpFile).withReader(){ reader -> String line @@ -74,7 +74,7 @@ class CO2FootprintConfig { CO2FootprintConfig(Map map, Map cpuData){ def config = map ?: Collections.emptyMap() - file = config.file ?: CO2FootprintFactory.CO2FootprintTextFileObserver.DEF_FILE_NAME + traceFile = config.traceFile ?: CO2FootprintFactory.CO2FootprintTextFileObserver.DEF_TRACE_FILE_NAME summaryFile = config.summaryFile ?: CO2FootprintFactory.CO2FootprintTextFileObserver.DEF_SUMMARY_FILE_NAME reportFile = config.reportFile ?: CO2FootprintFactory.CO2FootprintReportObserver.DEF_REPORT_FILE_NAME ignoreCpuModel = config.ignoreCpuModel ?: false @@ -98,7 +98,7 @@ class CO2FootprintConfig { loadCustomCpuTdpData(cpuData, config.customCpuTdpFile) } - String getFile() { file } + String getTraceFile() { traceFile } String getSummaryFile() { summaryFile } String getReportFile() { reportFile } Boolean getIgnoreCpuModel() { ignoreCpuModel } diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy index a9b2a1e..bb65776 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy @@ -2,7 +2,7 @@ * Copyright 2021, Seqera Labs * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * you may not use this traceFile except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 @@ -64,7 +64,7 @@ class CO2FootprintFactory implements TraceObserverFactory { Double total_co2 = 0 - // Load file containing TDP values for different CPU models + // Load traceFile containing TDP values for different CPU models protected void loadCpuTdpData(Map data) { def dataReader = new InputStreamReader(this.class.getResourceAsStream('/TDP_cpu.v2.2.csv')) @@ -87,10 +87,10 @@ class CO2FootprintFactory implements TraceObserverFactory { final result = new ArrayList(2) // Generate CO2 footprint text output files - def co2eFile = (this.config.getFile() as Path).complete() + def co2eTraceFile = (this.config.getTraceFile() as Path).complete() def co2eSummaryFile = (this.config.getSummaryFile() as Path).complete() - result.add( new CO2FootprintTextFileObserver(co2eFile, co2eSummaryFile) ) + result.add( new CO2FootprintTextFileObserver(co2eTraceFile, co2eSummaryFile) ) // Generate CO2 footprint report with box-plot def co2eReport = (this.config.getReportFile() as Path).complete() @@ -243,24 +243,24 @@ class CO2FootprintFactory implements TraceObserverFactory { class CO2FootprintTextFileObserver implements TraceObserver { // TODO which files should we generate here? - public static final String DEF_FILE_NAME = "co2footprint_trace_${TraceHelper.launchTimestampFmt()}.txt" + public static final String DEF_TRACE_FILE_NAME = "co2footprint_trace_${TraceHelper.launchTimestampFmt()}.txt" public static final String DEF_SUMMARY_FILE_NAME = "co2footprint_summary_${TraceHelper.launchTimestampFmt()}.txt" /** - * Overwrite existing trace file (required in some cases, as rolling filename has been deprecated) + * Overwrite existing trace traceFile (required in some cases, as rolling filename has been deprecated) */ boolean overwrite = true /** - * The path where the file is created. It is set by the object constructor + * The path where the traceFile is created. It is set by the object constructor */ - private Path co2ePath + private Path co2eTracePath private Path co2eSummaryPath /** - * The actual file object + * The actual traceFile object */ - private PrintWriter co2eFile + private PrintWriter co2eTraceFile private PrintWriter co2eSummaryFile @@ -271,17 +271,17 @@ class CO2FootprintFactory implements TraceObserverFactory { Map current = new ConcurrentHashMap<>() - private Agent writer + private Agent traceWriter private Agent summaryWriter /** * Create the trace observer * - * @param co2eFile A path to the file where save the CO2 emission data + * @param co2eTraceFile A path to the traceFile where save the CO2 emission data */ - CO2FootprintTextFileObserver(Path co2eFile, Path co2eSummaryFile) { - this.co2ePath = co2eFile + CO2FootprintTextFileObserver(Path co2eTraceFile, Path co2eSummaryFile) { + this.co2eTracePath = co2eTraceFile this.co2eSummaryPath = co2eSummaryFile } @@ -290,15 +290,15 @@ class CO2FootprintFactory implements TraceObserverFactory { /** - * Create the trace file, in file already existing with the same name it is - * "rolled" to a new file + * Create the trace traceFile, in traceFile already existing with the same name it is + * "rolled" to a new traceFile */ @Override void onFlowCreate(Session session) { - log.debug "Workflow started -- co2e file: ${co2ePath.toUriString()}" + log.debug "Workflow started -- co2e traceFile: ${co2eTracePath.toUriString()}" // make sure parent path exists - def parent = co2ePath.getParent() + def parent = co2eTracePath.getParent() if (parent) Files.createDirectories(parent) @@ -306,16 +306,16 @@ class CO2FootprintFactory implements TraceObserverFactory { if (summaryParent) Files.createDirectories(summaryParent) - // create a new trace file - co2eFile = new PrintWriter(TraceHelper.newFileWriter(co2ePath, overwrite, 'co2footprint')) + // create a new trace traceFile + co2eTraceFile = new PrintWriter(TraceHelper.newFileWriter(co2eTracePath, overwrite, 'co2footprint')) co2eSummaryFile = new PrintWriter(TraceHelper.newFileWriter(co2eSummaryPath, overwrite, 'co2footprintsummary')) // launch the agent - writer = new Agent(co2eFile) + traceWriter = new Agent(co2eTraceFile) summaryWriter = new Agent(co2eSummaryFile) String cpu_model_string = config.getIgnoreCpuModel()? "" : "cpu_model\t" - writer.send { co2eFile.println( + traceWriter.send { co2eTraceFile.println( "task_id\t" + "name\t" + "status\t" @@ -327,19 +327,19 @@ class CO2FootprintFactory implements TraceObserverFactory { + cpu_model_string + "cpu_usage\t" + "requested_memory" - ); co2eFile.flush() + ); co2eTraceFile.flush() } } /** - * Save the pending processes and close the trace file + * Save the pending processes and close the trace traceFile */ @Override void onFlowComplete() { - log.debug "Workflow completed -- saving trace file" + log.debug "Workflow completed -- saving trace traceFile" // wait for termination and flush the agent content - writer.await() + traceWriter.await() co2eSummaryFile.println("Total CO2e footprint measures of this workflow run") co2eSummaryFile.println("CO2e emissions: ${HelperFunctions.convertToReadableUnits(total_co2,3)}g") @@ -350,9 +350,9 @@ class CO2FootprintFactory implements TraceObserverFactory { co2eSummaryFile.close() // write the remaining records - current.values().each { taskId, record -> co2eFile.println("${taskId}\t-") } - co2eFile.flush() - co2eFile.close() + current.values().each { taskId, record -> co2eTraceFile.println("${taskId}\t-") } + co2eTraceFile.flush() + co2eTraceFile.close() // Log warnings if( hasWarnings() ) { @@ -425,9 +425,9 @@ class CO2FootprintFactory implements TraceObserverFactory { total_energy += eConsumption total_co2 += co2 - // save to the file + // save to the traceFile String cpu_model_string = config.getIgnoreCpuModel()? "" : "${trace.get('cpu_model').toString()}\t" - writer.send { + traceWriter.send { PrintWriter it -> it.println( "${taskId}\t" + "${trace.get('name').toString()}\t" @@ -478,9 +478,9 @@ class CO2FootprintFactory implements TraceObserverFactory { total_energy += eConsumption total_co2 += co2 - // save to the file + // save to the traceFile String cpu_model_string = config.getIgnoreCpuModel()? "" : "${trace.get('cpu_model').toString()}\t" - writer.send { + traceWriter.send { PrintWriter it -> it.println( "${taskId}\t" + "${trace.get('name').toString()}\t" @@ -520,7 +520,7 @@ class CO2FootprintFactory implements TraceObserverFactory { private Session session /** - * The path the HTML report file created + * The path the HTML report traceFile created */ private Path reportFile @@ -536,14 +536,14 @@ class CO2FootprintFactory implements TraceObserverFactory { private CO2FootprintResourcesAggregator aggregator /** - * Overwrite existing trace file (required in some cases, as rolling filename has been deprecated) + * Overwrite existing trace traceFile (required in some cases, as rolling filename has been deprecated) */ boolean overwrite /** * Creates a report observer * - * @param file The file path where to store the resulting HTML report document + * @param file The traceFile path where to store the resulting HTML report document */ CO2FootprintReportObserver(Path file ) { this.reportFile = file @@ -593,8 +593,8 @@ class CO2FootprintFactory implements TraceObserverFactory { } /** - * Create the trace file, in file already existing with the same name it is - * "rolled" to a new file + * Create the trace traceFile, in traceFile already existing with the same name it is + * "rolled" to a new traceFile */ @Override void onFlowCreate(Session session) { @@ -603,7 +603,7 @@ class CO2FootprintFactory implements TraceObserverFactory { } /** - * Save the pending processes and close the trace file + * Save the pending processes and close the trace traceFile */ @Override void onFlowComplete() { @@ -612,7 +612,7 @@ class CO2FootprintFactory implements TraceObserverFactory { renderHtml() } catch (Exception e) { - log.warn "Failed to render CO2e footprint report -- see the log file for details", e + log.warn "Failed to render CO2e footprint report -- see the log traceFile for details", e } } diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintPlugin.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintPlugin.groovy index 473749e..c899e8b 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintPlugin.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintPlugin.groovy @@ -2,7 +2,7 @@ * Copyright 2021, Seqera Labs * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * you may not use this traceFile except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintReportSummary.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintReportSummary.groovy index 9ae9983..fcfff7e 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintReportSummary.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintReportSummary.groovy @@ -2,7 +2,7 @@ * Copyright 2013-2023, Seqera Labs * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * you may not use this traceFile except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 diff --git a/plugins/nf-co2footprint/src/test/nextflow/co2footprint/CO2FootprintFactoryTest.groovy b/plugins/nf-co2footprint/src/test/nextflow/co2footprint/CO2FootprintFactoryTest.groovy index ca21835..734bd64 100644 --- a/plugins/nf-co2footprint/src/test/nextflow/co2footprint/CO2FootprintFactoryTest.groovy +++ b/plugins/nf-co2footprint/src/test/nextflow/co2footprint/CO2FootprintFactoryTest.groovy @@ -2,7 +2,7 @@ * Copyright 2021, Seqera Labs * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * you may not use this traceFile except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 diff --git a/plugins/nf-co2footprint/src/test/nextflow/co2footprint/TestHelper.groovy b/plugins/nf-co2footprint/src/test/nextflow/co2footprint/TestHelper.groovy index ffd51ab..c270f2b 100644 --- a/plugins/nf-co2footprint/src/test/nextflow/co2footprint/TestHelper.groovy +++ b/plugins/nf-co2footprint/src/test/nextflow/co2footprint/TestHelper.groovy @@ -3,7 +3,7 @@ * Copyright 2013-2019, Centre for Genomic Regulation (CRG) * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * you may not use this traceFile except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 @@ -33,7 +33,7 @@ class TestHelper { static private fs = Jimfs.newFileSystem(Configuration.unix()); - static Path createInMemTempFile(String name='temp.file', String content=null) { + static Path createInMemTempFile(String name='temp.traceFile', String content=null) { Path tmp = fs.getPath("/tmp"); tmp.mkdir() def result = Files.createTempDirectory(tmp, 'test').resolve(name)