From 6b442691665ecdb860b52e9415098084387b26da Mon Sep 17 00:00:00 2001 From: Cedric Zhuang Date: Wed, 20 Sep 2023 21:18:34 +0800 Subject: [PATCH] Allow user to omit credentials. Use could use `float login` to generate the credentials file. In this case, the credentials are not required in the nextflow configuration file. --- .../com/memverge/nextflow/FloatBin.groovy | 2 ++ .../com/memverge/nextflow/FloatConf.groovy | 21 +++++++------------ .../nextflow/FloatGridExecutor.groovy | 4 +++- .../main/com/memverge/nextflow/Global.groovy | 2 +- .../memverge/nextflow/FloatConfTest.groovy | 16 ++++++++++++-- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy index 5c71551..b87fcc2 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy @@ -23,6 +23,7 @@ class FloatBin { final Path pluginsDir = Global.getPluginsDir() ret = pluginsDir.resolve(binName) try { + log.info "try downloading $src to $ret" Global.download(src, ret) ret.setExecutable(true) } catch (Exception ex) { @@ -51,6 +52,7 @@ class FloatBin { for (String path : paths) { def floatPath = Paths.get(path).resolve(binName) if (Files.exists(floatPath)) { + log.info "found float binary in $path" return floatPath } } diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/FloatConf.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/FloatConf.groovy index b6b9763..d3b73f3 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/FloatConf.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/FloatConf.groovy @@ -37,7 +37,7 @@ class FloatConf { static final String NF_RUN_NAME = 'nextflow-io-run-name' static final String NF_SESSION_ID = 'nextflow-io-session-id' static final String NF_TASK_NAME = 'nextflow-io-task-name' - static final String NF_INPUT_SIZE = 'nextflow-io-input-size' + static final String NF_INPUT_SIZE = 'input-size' /** credentials for op center */ String username @@ -195,12 +195,6 @@ class FloatConf { } void validate() { - if (!username) { - throw new AbortOperationException("missing MMCE username") - } - if (!password) { - throw new AbortOperationException("missing MMCE password") - } if (addresses.size() == 0) { throw new AbortOperationException("missing MMCE OC address") } @@ -215,12 +209,13 @@ class FloatConf { List ret = [ bin.toString(), "-a", - address, - "-u", - username, - "-p", - password - ] + address] + if (username && password) { + ret.addAll(["-u", + username, + "-p", + password]) + } return ret } diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy index 6eb6c55..10940db 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy @@ -328,11 +328,13 @@ class FloatGridExecutor extends AbstractGridExecutor { throw new AbortOperationException("container is empty. " + "you can specify a default container image " + "with `process.container`") + } else { + log.info("got container image of the task ${container}") } def cmd = getSubmitCmdPrefix(task.index) cmd << 'submit' getMountVols(task).forEach { cmd << '--dataVolume' << it } - cmd << '--image' << task.getContainer() + cmd << '--image' << container cmd << '--cpu' << getCpu(task).toString() cmd << '--mem' << getMemory(task) cmd << '--job' << getScriptFilePath(handler, scriptFile) diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/Global.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/Global.groovy index 5e28e49..919779d 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/Global.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/Global.groovy @@ -98,7 +98,7 @@ class Global { } } } - log.info "download ${url} to ${filename}" + log.info "downloaded ${url} to ${filename}" // restore the factory and verifier HttpsURLConnection.setDefaultSSLSocketFactory(dftFactory) HttpsURLConnection.setDefaultHostnameVerifier(dftVerifier) diff --git a/plugins/nf-float/src/test/com/memverge/nextflow/FloatConfTest.groovy b/plugins/nf-float/src/test/com/memverge/nextflow/FloatConfTest.groovy index 2041d21..3d03ddf 100644 --- a/plugins/nf-float/src/test/com/memverge/nextflow/FloatConfTest.groovy +++ b/plugins/nf-float/src/test/com/memverge/nextflow/FloatConfTest.groovy @@ -90,10 +90,10 @@ class FloatConfTest extends BaseTest { "-u admin -p password" } - def "credentials are required"() { + def "address is required"() { given: def conf = [ - float: [address: '1.2.3.4']] + float: [username: 'admin']] when: def fConf = FloatConf.getConf(conf) @@ -103,6 +103,18 @@ class FloatConfTest extends BaseTest { thrown AbortOperationException } + def "credentials are optional"() { + given: + def conf = [float:[address:"1.2.3.4"]] + + when: + def fConf = FloatConf.getConf(conf) + fConf.validate() + + then: + fConf.getCliPrefix().join(' ').endsWith('float -a 1.2.3.4') + } + def "get s3 data volume"() { given: def conf = [