@@ -48,6 +48,7 @@ import java.util.concurrent.ConcurrentHashMap
48
48
@PackageScope (PackageScopeTarget .FIELDS )
49
49
class CO2FootprintFactory implements TraceObserverFactory {
50
50
51
+ private String version
51
52
// Handle logging messages
52
53
private List<String > warnings = []
53
54
@@ -63,6 +64,15 @@ class CO2FootprintFactory implements TraceObserverFactory {
63
64
Double total_energy = 0
64
65
Double total_co2 = 0
65
66
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
+ }
66
76
67
77
// Load file containing TDP values for different CPU models
68
78
protected void loadCpuTdpData (Map<String , Double > data ) {
@@ -80,6 +90,9 @@ class CO2FootprintFactory implements TraceObserverFactory {
80
90
81
91
@Override
82
92
Collection<TraceObserver > create (Session session ) {
93
+ getPluginVersion()
94
+ log. info " nf-co2footprint plugin ~ version ${ this.version} "
95
+
83
96
loadCpuTdpData(this . cpuData)
84
97
85
98
this . session = session
@@ -744,12 +757,12 @@ class CO2FootprintFactory implements TraceObserverFactory {
744
757
* Render the report HTML document
745
758
*/
746
759
protected void renderHtml () {
747
-
748
760
// render HTML report template
749
761
final tpl_fields = [
750
762
workflow : getWorkflowMetadata(),
751
763
payload : renderPayloadJson(),
752
764
co2_totals : renderCO2TotalsJson(),
765
+ plugin_version : version,
753
766
assets_css : [
754
767
readTemplate(' nextflow/trace/assets/bootstrap.min.css' ),
755
768
readTemplate(' nextflow/trace/assets/datatables.min.css' )
0 commit comments