From eb2da47cade74bb696a897a36c8c803528ca6aa0 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 1 Jun 2019 12:06:08 +0200 Subject: [PATCH] Fix Disable ansi logging when using kuberun command #1161 This commit disables the rich ansi logging feature when using the `kuberun` command since the output is not rendered correctly. Likely this is due to the wrong encoding of ANSI escape code when written/read over the http api. --- .../nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy | 4 ++++ .../nextflow/src/main/groovy/nextflow/cli/CmdKubeRun.groovy | 4 ++++ modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy | 4 ++-- .../src/main/groovy/nextflow/k8s/K8sDriverLauncher.groovy | 1 + .../test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy | 6 ++++-- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy index ce4ae2e36e..08c259cf10 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy @@ -109,4 +109,8 @@ class CliOptions { return Ansi.isEnabled() } + boolean hasAnsiLogFlag() { + ansiLog==true || System.getenv('NXF_ANSI_LOG')=='true' + } + } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdKubeRun.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdKubeRun.groovy index ad769694a7..64d449f7df 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdKubeRun.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdKubeRun.groovy @@ -59,12 +59,16 @@ class CmdKubeRun extends CmdRun { protected boolean background() { launcher.options.background } + protected hasAnsiLogFlag() { launcher.options.hasAnsiLogFlag() } + @Override void run() { final scriptArgs = (args?.size()>1 ? args[1..-1] : []) as List final pipeline = stdin ? '-' : ( args ? args[0] : null ) if( !pipeline ) throw new AbortOperationException("No project name was specified") + if( hasAnsiLogFlag() ) + log.warn "Ansi logging not supported by kuberun command" checkRunName() new K8sDriverLauncher(cmd: this, runName: runName, podImage: podImage, background: background()) .run(pipeline, scriptArgs) diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy index 46e23619af..a8276d1fa9 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy @@ -130,12 +130,12 @@ class CmdRun extends CmdBase implements HubOptions { boolean stdin @Parameter(names = ['-ansi'], hidden = true, arity = 0) - boolean setAnsi(boolean value) { + void setAnsi(boolean value) { launcher.options.ansiLog = value } @Parameter(names = ['-ansi-log'], description = 'Enable/disable ANSI console logging', arity = 1) - boolean setAnsiLog(boolean value) { + void setAnsiLog(boolean value) { launcher.options.ansiLog = value } diff --git a/modules/nextflow/src/main/groovy/nextflow/k8s/K8sDriverLauncher.groovy b/modules/nextflow/src/main/groovy/nextflow/k8s/K8sDriverLauncher.groovy index 3907f87501..83841b2d0a 100644 --- a/modules/nextflow/src/main/groovy/nextflow/k8s/K8sDriverLauncher.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/k8s/K8sDriverLauncher.groovy @@ -417,6 +417,7 @@ class K8sDriverLauncher { .withEnv( PodEnv.value('NXF_WORK', k8sConfig.getWorkDir()) ) .withEnv( PodEnv.value('NXF_ASSETS', k8sConfig.getProjectDir()) ) .withEnv( PodEnv.value('NXF_EXECUTOR', 'k8s')) + .withEnv( PodEnv.value('NXF_ANSI_LOG', 'false')) .build() // note: do *not* set the work directory because it may need to be created by the init script diff --git a/modules/nextflow/src/test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy b/modules/nextflow/src/test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy index d4a13be133..b42533a1a1 100644 --- a/modules/nextflow/src/test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy @@ -166,7 +166,8 @@ class K8sDriverLauncherTest extends Specification { env:[ [name:'NXF_WORK', value:'/the/work/dir'], [name:'NXF_ASSETS', value:'/the/project/dir'], - [name:'NXF_EXECUTOR', value:'k8s']], + [name:'NXF_EXECUTOR', value:'k8s'], + [name:'NXF_ANSI_LOG', value: 'false']], volumeMounts:[ [name:'vol-1', mountPath:'/mnt/path/data'], [name:'vol-2', mountPath:'/mnt/path/cfg']]] @@ -214,7 +215,8 @@ class K8sDriverLauncherTest extends Specification { env:[ [name:'NXF_WORK', value:'/the/work/dir'], [name:'NXF_ASSETS', value:'/the/project/dir'], - [name:'NXF_EXECUTOR', value:'k8s']], + [name:'NXF_EXECUTOR', value:'k8s'], + [name:'NXF_ANSI_LOG', value: 'false'] ], volumeMounts:[ [name:'vol-1', mountPath:'/mnt/path/data'], [name:'vol-2', mountPath:'/mnt/path/cfg']]]