diff --git a/CHANGELOG.md b/CHANGELOG.md index 1de7b11..325d13c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [Unreleased] + +### `Added` + +- [#86](https://github.com/nextflow-io/nf-co2footprint/pull/86) Report nf-co2footprint version in `co2footprint_report_*.html` and `co2footprint_summary_*.txt` reports. + ## Version 1.0.0-beta Initial pre-release. \ No newline at end of file diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy index 02bd093..28d6afa 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy @@ -48,6 +48,7 @@ import java.util.concurrent.ConcurrentHashMap @PackageScope(PackageScopeTarget.FIELDS) class CO2FootprintFactory implements TraceObserverFactory { + private String version // Handle logging messages private List warnings = [] @@ -63,6 +64,15 @@ class CO2FootprintFactory implements TraceObserverFactory { Double total_energy = 0 Double total_co2 = 0 + protected void getPluginVersion() { + def reader = new InputStreamReader(this.class.getResourceAsStream('/META-INF/MANIFEST.MF')) + String line + while ( (line = reader.readLine()) && !version ) { + def h = line.split(": ") + if ( h[0] == 'Plugin-Version' ) this.version = h[1] + } + reader.close() + } // Load file containing TDP values for different CPU models protected void loadCpuTdpData(Map data) { @@ -80,6 +90,9 @@ class CO2FootprintFactory implements TraceObserverFactory { @Override Collection create(Session session) { + getPluginVersion() + log.info "nf-co2footprint plugin ~ version ${this.version}" + loadCpuTdpData(this.cpuData) this.session = session @@ -348,6 +361,8 @@ class CO2FootprintFactory implements TraceObserverFactory { co2eSummaryFile.println("Energy consumption: ${HelperFunctions.convertToReadableUnits(total_energy,3)}Wh") co2eSummaryFile.println("\nThe calculation of these values is based on the carbon footprint computation method developed in the Green Algorithms project.") co2eSummaryFile.println("Lannelongue, L., Grealey, J., Inouye, M., Green Algorithms: Quantifying the Carbon Footprint of Computation. Adv. Sci. 2021, 2100707. https://doi.org/10.1002/advs.202100707") + co2eSummaryFile.println() + co2eSummaryFile.println("nf-co2footprint plugin version: ${version}") co2eSummaryFile.flush() co2eSummaryFile.close() @@ -744,12 +759,12 @@ class CO2FootprintFactory implements TraceObserverFactory { * Render the report HTML document */ protected void renderHtml() { - // render HTML report template final tpl_fields = [ workflow : getWorkflowMetadata(), payload : renderPayloadJson(), co2_totals: renderCO2TotalsJson(), + plugin_version: version, assets_css : [ readTemplate('nextflow/trace/assets/bootstrap.min.css'), readTemplate('nextflow/trace/assets/datatables.min.css') diff --git a/plugins/nf-co2footprint/src/resources/CO2FootprintReportTemplate.html b/plugins/nf-co2footprint/src/resources/CO2FootprintReportTemplate.html index 94c4795..6d71a90 100644 --- a/plugins/nf-co2footprint/src/resources/CO2FootprintReportTemplate.html +++ b/plugins/nf-co2footprint/src/resources/CO2FootprintReportTemplate.html @@ -180,6 +180,9 @@

Workflow execution completed unsuccessfully!

Nextflow version
version ${workflow.nextflow.version}, build ${workflow.nextflow.build} (${workflow.nextflow.timestamp})
+ +
nf-co2footprint plugin version
+
version ${plugin_version}

Total CO2e footprint measures