Skip to content

Commit

Permalink
Merge pull request #86 from skrakau/report_version
Browse files Browse the repository at this point in the history
Report nf-co2footprint version
  • Loading branch information
skrakau authored Jan 31, 2024
2 parents c213bff + 5fbc9e0 commit 2df5664
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import java.util.concurrent.ConcurrentHashMap
@PackageScope(PackageScopeTarget.FIELDS)
class CO2FootprintFactory implements TraceObserverFactory {

private String version
// Handle logging messages
private List<String> warnings = []

Expand All @@ -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<String, Double> data) {
Expand All @@ -80,6 +90,9 @@ class CO2FootprintFactory implements TraceObserverFactory {

@Override
Collection<TraceObserver> create(Session session) {
getPluginVersion()
log.info "nf-co2footprint plugin ~ version ${this.version}"

loadCpuTdpData(this.cpuData)

this.session = session
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ <h4>Workflow execution completed unsuccessfully!</h4>
<dl>
<dt>Nextflow version</dt>
<dd>version ${workflow.nextflow.version}, build ${workflow.nextflow.build} (${workflow.nextflow.timestamp})</dd>

<dt>nf-co2footprint plugin version</dt>
<dd>version ${plugin_version}</dd>
</dl>

<h3 class="mt-5">Total CO<sub>2</sub>e footprint measures</h3>
Expand Down

0 comments on commit 2df5664

Please sign in to comment.