Skip to content

Commit 9623d35

Browse files
committed
Retrieve and report nf-co2footprint version
1 parent c213bff commit 9623d35

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import java.util.concurrent.ConcurrentHashMap
4848
@PackageScope(PackageScopeTarget.FIELDS)
4949
class CO2FootprintFactory implements TraceObserverFactory {
5050

51+
private String version
5152
// Handle logging messages
5253
private List<String> warnings = []
5354

@@ -63,6 +64,15 @@ class CO2FootprintFactory implements TraceObserverFactory {
6364
Double total_energy = 0
6465
Double total_co2 = 0
6566

67+
protected void getPluginVersion() {
68+
def reader = new InputStreamReader(this.class.getResourceAsStream('/META-INF/MANIFEST.MF'))
69+
String line
70+
while ( (line = reader.readLine()) && !version ) {
71+
def h = line.split(": ")
72+
if ( h[0] == 'Plugin-Version' ) this.version = h[1]
73+
}
74+
reader.close()
75+
}
6676

6777
// Load file containing TDP values for different CPU models
6878
protected void loadCpuTdpData(Map<String, Double> data) {
@@ -80,6 +90,9 @@ class CO2FootprintFactory implements TraceObserverFactory {
8090

8191
@Override
8292
Collection<TraceObserver> create(Session session) {
93+
getPluginVersion()
94+
log.info "nf-co2footprint plugin ~ version ${this.version}"
95+
8396
loadCpuTdpData(this.cpuData)
8497

8598
this.session = session
@@ -744,12 +757,12 @@ class CO2FootprintFactory implements TraceObserverFactory {
744757
* Render the report HTML document
745758
*/
746759
protected void renderHtml() {
747-
748760
// render HTML report template
749761
final tpl_fields = [
750762
workflow : getWorkflowMetadata(),
751763
payload : renderPayloadJson(),
752764
co2_totals: renderCO2TotalsJson(),
765+
plugin_version: version,
753766
assets_css : [
754767
readTemplate('nextflow/trace/assets/bootstrap.min.css'),
755768
readTemplate('nextflow/trace/assets/datatables.min.css')

plugins/nf-co2footprint/src/resources/CO2FootprintReportTemplate.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ <h4>Workflow execution completed unsuccessfully!</h4>
180180
<dl>
181181
<dt>Nextflow version</dt>
182182
<dd>version ${workflow.nextflow.version}, build ${workflow.nextflow.build} (${workflow.nextflow.timestamp})</dd>
183+
184+
<dt>nf-co2footprint plugin version</dt>
185+
<dd>version ${plugin_version}</dd>
183186
</dl>
184187

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

0 commit comments

Comments
 (0)