Skip to content

Commit 80c3e23

Browse files
pinin4fjordsclaude
andcommitted
Address review feedback: simplify ConfigScope registration
Per Ben's review, only the top-level scope needs @ScopeName, a no-arg constructor, and extension point registration. Nested scopes are discovered via fields on the parent class. - Register CO2FootprintConfig in build.gradle extensionPoints - Remove @ScopeName from nested scope classes (Trace/Summary/Report/DataFileConfig) - Remove no-arg constructors from nested scopes and BaseFileConfig - Remove unnecessary types=[...] from @ConfigOption annotations (kept types=[Number, BigDecimal] on ci since it constructs CiRecord from a number) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Jonathan Manning <[email protected]>
1 parent 2745da2 commit 80c3e23

7 files changed

Lines changed: 15 additions & 32 deletions

File tree

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ nextflowPlugin {
107107
className = 'nextflow.co2footprint.CO2FootprintPlugin'
108108
extensionPoints = [
109109
'nextflow.co2footprint.CO2FootprintFactory',
110-
'nextflow.co2footprint.CO2FootprintExtension'
110+
'nextflow.co2footprint.CO2FootprintExtension',
111+
'nextflow.co2footprint.CO2FootprintConfig'
111112
]
112113

113114
}

src/main/nextflow/co2footprint/CO2FootprintConfig.groovy

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,59 +57,59 @@ class CO2FootprintConfig implements ConfigScope {
5757
private final String timestamp = TraceHelper.launchTimestampFmt()
5858
private final String executor
5959

60-
@ConfigOption(types=[Map])
60+
@ConfigOption
6161
@Description('Configuration for the trace file.')
6262
final TraceFileConfig trace
6363

64-
@ConfigOption(types=[Map])
64+
@ConfigOption
6565
@Description('Configuration for the summary file.')
6666
final SummaryFileConfig summary
6767

68-
@ConfigOption(types=[Map])
68+
@ConfigOption
6969
@Description('Configuration for the report file.')
7070
final ReportFileConfig report
7171

72-
@ConfigOption(types=[Map])
72+
@ConfigOption
7373
@Description('Configuration for the data/machine-readable file.')
7474
final DataFileConfig dataFile
7575

76-
@ConfigOption(types=[GString])
76+
@ConfigOption
7777
@Description('Location GeoCode from Electricity maps.')
7878
final String location
7979

8080
@ConfigOption(types=[Number, BigDecimal])
8181
@Description('Location-based carbon intensity (CI).')
8282
final CiRecord ci
8383

84-
@ConfigOption(types=[Number])
84+
@ConfigOption
8585
@Description('Market-based carbon intensity (CI).')
8686
final BigDecimal ciMarket
8787

88-
@ConfigOption(types=[GString])
88+
@ConfigOption
8989
@Description('Electricity-maps API token.')
9090
final String emApiKey
9191

92-
@ConfigOption(types=[Number])
92+
@ConfigOption
9393
@Description('Power usage effectiveness (PUE) of the data centre.')
9494
BigDecimal pue
9595

96-
@ConfigOption(types=[Number])
96+
@ConfigOption
9797
@Description('Power draw of memory [W per GB].')
9898
final BigDecimal powerdrawMem
9999

100100
@ConfigOption
101101
@Description('Turns off pattern matching of CPU names.')
102102
final Boolean ignoreCpuModel
103103

104-
@ConfigOption(types=[Number])
104+
@ConfigOption
105105
@Description('Default powerdraw of the CPU.')
106106
final BigDecimal powerdrawCpuDefault
107107

108-
@ConfigOption(types=[String, GString])
108+
@ConfigOption
109109
@Description('Path to a custom CPU TDP file.')
110110
final Path customCpuTdpFile
111111

112-
@ConfigOption(types=[GString])
112+
@ConfigOption
113113
@Description('Type of computer on which the workflow is run [\'local\', \'compute cluster\', \'\'].')
114114
String machineType
115115

src/main/nextflow/co2footprint/Config/BaseFileConfig.groovy

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BaseFileConfig {
1818
final String name
1919
final String ending
2020

21-
@ConfigOption(types=[String, GString])
21+
@ConfigOption
2222
@Description('Path to the file.')
2323
final Path file
2424

@@ -32,12 +32,6 @@ class BaseFileConfig {
3232

3333
protected final LinkedHashSet<String> usedKeys = [] as LinkedHashSet<String>
3434

35-
/**
36-
* No-arg constructor required by Nextflow's v2 config parser for
37-
* subclasses that implement ConfigScope.
38-
*/
39-
protected BaseFileConfig() {}
40-
4135
/**
4236
* Parses a file-based sub-configuration for nf-co2footprint and sets up defaults and fallbacks.
4337
*

src/main/nextflow/co2footprint/Config/DataFileConfig.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ package nextflow.co2footprint.Config
33
import nextflow.co2footprint.CO2FootprintConfig
44
import nextflow.config.spec.ConfigOption
55
import nextflow.config.spec.ConfigScope
6-
import nextflow.config.spec.ScopeName
76
import nextflow.script.dsl.Description
87

9-
@ScopeName('co2footprint.dataFile')
108
@Description('The `co2footprint.dataFile` scope allows you to configure the data/machine-actionable file of the `nf-co2footprint` plugin.')
119
class DataFileConfig extends BaseFileConfig implements ConfigScope {
12-
DataFileConfig() { super() }
1310

1411
@ConfigOption
1512
@Description('Whether only emission metrics should be reported in the data file.')

src/main/nextflow/co2footprint/Config/ReportFileConfig.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ package nextflow.co2footprint.Config
33
import nextflow.co2footprint.CO2FootprintConfig
44
import nextflow.config.spec.ConfigOption
55
import nextflow.config.spec.ConfigScope
6-
import nextflow.config.spec.ScopeName
76
import nextflow.script.dsl.Description
87

9-
@ScopeName('co2footprint.report')
108
@Description('The `co2footprint.report` scope allows you to configure the report file of the `nf-co2footprint` plugin.')
119
class ReportFileConfig extends BaseFileConfig implements ConfigScope{
12-
ReportFileConfig() { super() }
1310

1411
@ConfigOption
1512
@Description('The number of maximum tasks that is displayed in the report.')

src/main/nextflow/co2footprint/Config/SummaryFileConfig.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ package nextflow.co2footprint.Config
22

33
import nextflow.co2footprint.CO2FootprintConfig
44
import nextflow.config.spec.ConfigScope
5-
import nextflow.config.spec.ScopeName
65
import nextflow.script.dsl.Description
76

8-
@ScopeName('co2footprint.summary')
97
@Description('The `co2footprint.summary` scope allows you to configure the summary file of the `nf-co2footprint` plugin.')
108
class SummaryFileConfig extends BaseFileConfig implements ConfigScope{
11-
SummaryFileConfig() { super() }
129
SummaryFileConfig(Map summaryFileConfig, String timestamp=null) {
1310
super(summaryFileConfig, timestamp, 'summary', 'txt')
1411

src/main/nextflow/co2footprint/Config/TraceFileConfig.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ package nextflow.co2footprint.Config
22

33
import nextflow.co2footprint.CO2FootprintConfig
44
import nextflow.config.spec.ConfigScope
5-
import nextflow.config.spec.ScopeName
65
import nextflow.script.dsl.Description
76

8-
@ScopeName('co2footprint.trace')
97
@Description('The `co2footprint.trace` scope allows you to configure the trace file of the `nf-co2footprint` plugin.')
108
class TraceFileConfig extends BaseFileConfig implements ConfigScope{
11-
TraceFileConfig() { super() }
129
TraceFileConfig(Map traceFileConfig, String timestamp=null) {
1310
super(traceFileConfig, timestamp, 'trace', 'txt')
1411

0 commit comments

Comments
 (0)