Skip to content

Commit

Permalink
Fix Disable ansi logging when using kuberun command nextflow-io#1161
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pditommaso authored and sivkovic committed Jun 6, 2019
1 parent ed80517 commit eb2da47
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
Expand Up @@ -109,4 +109,8 @@ class CliOptions {
return Ansi.isEnabled()
}

boolean hasAnsiLogFlag() {
ansiLog==true || System.getenv('NXF_ANSI_LOG')=='true'
}

}
Expand Up @@ -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<String>
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)
Expand Down
4 changes: 2 additions & 2 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy
Expand Up @@ -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
}

Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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']]]
Expand Down Expand Up @@ -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']]]
Expand Down

0 comments on commit eb2da47

Please sign in to comment.