Skip to content

Commit 9cc8653

Browse files
authored
Merge pull request #379 from JosuaCarl/fix-report-removal
Fix: Cloned value, so representation map does not get deleted
2 parents ae92808 + 1395a2c commit 9cc8653

4 files changed

Lines changed: 147 additions & 68 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# New
22
## Bug Fixes:
3+
- Unintended report value removal
34

45
## Misc:
56
- Improved workflow reporting form extension/CLI by deriving and injecting workflow metadata from the provided trace file

src/main/nextflow/co2footprint/Records/CO2RecordTree.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class CO2RecordTree {
207207
Map<String, Map<String, Object>> recordMap = [:]
208208
if (co2Record) {
209209
(emissionMetricsOnly ? co2Record.emissionMetrics : co2Record.keySet()).each { String key ->
210-
Map<String, Object> value = co2Record.representationMap.get(key)
210+
Map<String, Object> value = co2Record.representationMap.get(key).clone() as Map<String, Object>
211211
if (includeNulls || value['raw']['value'] != null) {
212212
if (!includeReportValues) {
213213
value.remove('report')
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"test_tree.yaml": {
3-
"checksum": "db960cf5b1e8f30b0c49bddbd98a6b08",
4-
"num_lines": 137
3+
"checksum": "a19e44d789eeeb7b0c3dbb973609f496",
4+
"num_lines": 215
55
}
66
}

src/testResources/tree/test_tree.yaml

Lines changed: 143 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -44,94 +44,172 @@ children:
4444
- name: test1
4545
metaData: {level: process}
4646
values:
47-
task_id: &id001
48-
raw: {value: '111', type: str}
47+
task_id:
48+
raw: &id001 {value: '111', type: str}
4949
readable: '111'
50-
status: &id002
51-
raw: {value: COMPLETED, type: str}
50+
status:
51+
raw: &id002 {value: COMPLETED, type: str}
5252
readable: COMPLETED
53-
energy_consumption: &id003
54-
raw: {value: 2000.0, type: Number, unit: Wh, scale: ''}
53+
energy_consumption:
54+
raw: &id003 {value: 2000.0, type: Number, unit: Wh, scale: ''}
5555
readable: 2 kWh
56-
CO2e: &id004
57-
raw: {value: 200.0, type: Number, unit: g, scale: ''}
56+
CO2e:
57+
raw: &id004 {value: 200.0, type: Number, unit: g, scale: ''}
5858
readable: 200 g
59-
carbon_intensity: &id005
60-
raw: {value: 100.0, type: Number, unit: gCO₂e/kWh, scale: ''}
59+
carbon_intensity:
60+
raw: &id005 {value: 100.0, type: Number, unit: gCO₂e/kWh, scale: ''}
6161
readable: 100 gCO₂e/kWh
62-
'%cpu': &id006
63-
raw: {value: 1.0, type: Percentage, unit: '', scale: '%'}
62+
'%cpu':
63+
raw: &id006 {value: 1.0, type: Percentage, unit: '', scale: '%'}
6464
readable: 1 %
65-
memory: &id007
66-
raw: {value: 10737418240, type: Bytes, unit: B, scale: ''}
65+
memory:
66+
raw: &id007 {value: 10737418240, type: Bytes, unit: B, scale: ''}
6767
readable: 10 GB
68-
realtime: &id008
69-
raw: {value: 3600000.0000, type: Duration, unit: ms, scale: ''}
68+
realtime:
69+
raw: &id008 {value: 3600000.0000, type: Duration, unit: ms, scale: ''}
7070
readable: 1h
71-
cpus: &id009
72-
raw: {value: 1, type: Number, unit: '', scale: ''}
71+
cpus:
72+
raw: &id009 {value: 1, type: Number, unit: '', scale: ''}
7373
readable: '1'
74-
powerdraw_cpu: &id010
75-
raw: {value: 7.0, type: Number, unit: W, scale: ''}
74+
powerdraw_cpu:
75+
raw: &id010 {value: 7.0, type: Number, unit: W, scale: ''}
7676
readable: 7 W
77-
cpu_model: &id011
78-
raw: {value: Some model, type: str}
77+
cpu_model:
78+
raw: &id011 {value: Some model, type: str}
7979
readable: Some model
80-
raw_energy_processor: &id012
81-
raw: {value: 5000.0, type: Number, unit: Wh, scale: ''}
80+
raw_energy_processor:
81+
raw: &id012 {value: 5000.0, type: Number, unit: Wh, scale: ''}
8282
readable: 5 kWh
83-
raw_energy_memory: &id013
84-
raw: {value: 5000.0, type: Number, unit: Wh, scale: ''}
83+
raw_energy_memory:
84+
raw: &id013 {value: 5000.0, type: Number, unit: Wh, scale: ''}
8585
readable: 5 kWh
8686
children:
8787
- name: '1'
8888
metaData: {level: task}
8989
values:
90-
task_id: *id001
91-
status: *id002
92-
energy_consumption: *id003
93-
CO2e: *id004
94-
carbon_intensity: *id005
95-
'%cpu': *id006
96-
memory: *id007
97-
realtime: *id008
98-
cpus: *id009
99-
powerdraw_cpu: *id010
100-
cpu_model: *id011
101-
raw_energy_processor: *id012
102-
raw_energy_memory: *id013
90+
task_id:
91+
raw: *id001
92+
readable: '111'
93+
status:
94+
raw: *id002
95+
readable: COMPLETED
96+
energy_consumption:
97+
raw: *id003
98+
readable: 2 kWh
99+
CO2e:
100+
raw: *id004
101+
readable: 200 g
102+
carbon_intensity:
103+
raw: *id005
104+
readable: 100 gCO₂e/kWh
105+
'%cpu':
106+
raw: *id006
107+
readable: 1 %
108+
memory:
109+
raw: *id007
110+
readable: 10 GB
111+
realtime:
112+
raw: *id008
113+
readable: 1h
114+
cpus:
115+
raw: *id009
116+
readable: '1'
117+
powerdraw_cpu:
118+
raw: *id010
119+
readable: 7 W
120+
cpu_model:
121+
raw: *id011
122+
readable: Some model
123+
raw_energy_processor:
124+
raw: *id012
125+
readable: 5 kWh
126+
raw_energy_memory:
127+
raw: *id013
128+
readable: 5 kWh
103129
children: []
104130
- name: test2
105131
metaData: {level: process}
106132
values:
107-
task_id: *id001
108-
status: *id002
109-
energy_consumption: *id003
110-
CO2e: *id004
111-
carbon_intensity: *id005
112-
'%cpu': *id006
113-
memory: *id007
114-
realtime: *id008
115-
cpus: *id009
116-
powerdraw_cpu: *id010
117-
cpu_model: *id011
118-
raw_energy_processor: *id012
119-
raw_energy_memory: *id013
133+
task_id:
134+
raw: *id001
135+
readable: '111'
136+
status:
137+
raw: *id002
138+
readable: COMPLETED
139+
energy_consumption:
140+
raw: *id003
141+
readable: 2 kWh
142+
CO2e:
143+
raw: *id004
144+
readable: 200 g
145+
carbon_intensity:
146+
raw: *id005
147+
readable: 100 gCO₂e/kWh
148+
'%cpu':
149+
raw: *id006
150+
readable: 1 %
151+
memory:
152+
raw: *id007
153+
readable: 10 GB
154+
realtime:
155+
raw: *id008
156+
readable: 1h
157+
cpus:
158+
raw: *id009
159+
readable: '1'
160+
powerdraw_cpu:
161+
raw: *id010
162+
readable: 7 W
163+
cpu_model:
164+
raw: *id011
165+
readable: Some model
166+
raw_energy_processor:
167+
raw: *id012
168+
readable: 5 kWh
169+
raw_energy_memory:
170+
raw: *id013
171+
readable: 5 kWh
120172
children:
121173
- name: '2'
122174
metaData: {level: task}
123175
values:
124-
task_id: *id001
125-
status: *id002
126-
energy_consumption: *id003
127-
CO2e: *id004
128-
carbon_intensity: *id005
129-
'%cpu': *id006
130-
memory: *id007
131-
realtime: *id008
132-
cpus: *id009
133-
powerdraw_cpu: *id010
134-
cpu_model: *id011
135-
raw_energy_processor: *id012
136-
raw_energy_memory: *id013
176+
task_id:
177+
raw: *id001
178+
readable: '111'
179+
status:
180+
raw: *id002
181+
readable: COMPLETED
182+
energy_consumption:
183+
raw: *id003
184+
readable: 2 kWh
185+
CO2e:
186+
raw: *id004
187+
readable: 200 g
188+
carbon_intensity:
189+
raw: *id005
190+
readable: 100 gCO₂e/kWh
191+
'%cpu':
192+
raw: *id006
193+
readable: 1 %
194+
memory:
195+
raw: *id007
196+
readable: 10 GB
197+
realtime:
198+
raw: *id008
199+
readable: 1h
200+
cpus:
201+
raw: *id009
202+
readable: '1'
203+
powerdraw_cpu:
204+
raw: *id010
205+
readable: 7 W
206+
cpu_model:
207+
raw: *id011
208+
readable: Some model
209+
raw_energy_processor:
210+
raw: *id012
211+
readable: 5 kWh
212+
raw_energy_memory:
213+
raw: *id013
214+
readable: 5 kWh
137215
children: []

0 commit comments

Comments
 (0)