Skip to content

Commit 5aaf792

Browse files
jorgeebentsherman
authored andcommitted
Fix resolution of params in resolved config text (#7072)
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 4656c9b commit 5aaf792

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class CmdRun extends CmdBase implements HubOptions {
406406
final isTowerEnabled = config.navigate('tower.enabled') as Boolean
407407
final isDataEnabled = config.navigate("lineage.enabled") as Boolean
408408
if( isTowerEnabled || isDataEnabled || log.isTraceEnabled() )
409-
runner.session.resolvedConfig = ConfigBuilder.resolveConfig(scriptFile.parent, this)
409+
runner.session.resolvedConfig = ConfigBuilder.resolveConfig(scriptFile.parent, this, cliParams)
410410
// note config files are collected during the build process
411411
// this line should be after `ConfigBuilder#build`
412412
runner.session.configFiles = builder.parsedConfigFiles

modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,13 +919,14 @@ class ConfigBuilder {
919919
}
920920
}
921921

922-
static String resolveConfig(Path baseDir, CmdRun cmdRun) {
922+
static String resolveConfig(Path baseDir, CmdRun cmdRun, Map cliParams) {
923923

924924
final config = new ConfigBuilder()
925925
.setShowClosures(true)
926926
.setStripSecrets(true)
927927
.setOptions(cmdRun.launcher.options)
928928
.setCmdRun(cmdRun)
929+
.setCliParams(cliParams)
929930
.setBaseDir(baseDir)
930931
.buildConfigObject()
931932

modules/nextflow/src/test/groovy/nextflow/config/ConfigBuilderTest.groovy

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,9 +2410,9 @@ class ConfigBuilderTest extends Specification {
24102410

24112411
def 'should return parsed config' () {
24122412
given:
2413-
def cmd = new CmdRun(profile: 'first', withTower: 'http://foo.com', launcher: new Launcher())
24142413
def base = Files.createTempDirectory('test')
2415-
base.resolve('nextflow.config').text = '''
2414+
def configFile = base.resolve('nextflow.config')
2415+
configFile.text = '''
24162416
profiles {
24172417
first {
24182418
params {
@@ -2422,25 +2422,31 @@ class ConfigBuilderTest extends Specification {
24222422
process {
24232423
executor = { 'local' }
24242424
}
2425+
outputDir = params.outdir
24252426
}
24262427
second {
24272428
params.none = 'Blah'
24282429
}
24292430
}
24302431
'''
24312432
when:
2432-
def txt = ConfigBuilder.resolveConfig(base, cmd)
2433+
def opt = new CliOptions(config: [configFile.toFile().canonicalPath])
2434+
def cmd = new CmdRun(profile: 'first', withTower: 'http://foo.com', launcher: new Launcher(options: opt))
2435+
def cliParams = [foo: 'Hola', outdir: 'output_folder']
2436+
def txt = ConfigBuilder.resolveConfig(base, cmd, cliParams)
24332437
then:
24342438
txt == '''\
24352439
params {
2436-
foo = 'Hello world'
2440+
foo = 'Hola'
24372441
awsKey = '[secret]'
2442+
outdir = 'output_folder'
24382443
}
24392444
24402445
process {
24412446
executor = { 'local' }
24422447
}
24432448
2449+
outputDir = 'output_folder'
24442450
workDir = 'work'
24452451
24462452
tower {

0 commit comments

Comments
 (0)