From 87eec325b934f5cbbc0b569037cb06b31187d015 Mon Sep 17 00:00:00 2001 From: Cedric Zhuang Date: Tue, 11 Jul 2023 15:59:52 +0800 Subject: [PATCH] [GH-32] Upload bin directory. If the workflow contains a bin directory, upload to a tmp directory in the working directory. In `.command.run` script, we add `export PATH=...` to include the tmp directory. --- .../nextflow/FloatGridExecutor.groovy | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) 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 069c43c..beea369 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy @@ -18,6 +18,7 @@ package com.memverge.nextflow import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import nextflow.executor.AbstractGridExecutor +import nextflow.extension.FilesEx import nextflow.processor.TaskConfig import nextflow.processor.TaskRun import nextflow.util.ServiceName @@ -38,6 +39,8 @@ class FloatGridExecutor extends AbstractGridExecutor { private AtomicInteger serial = new AtomicInteger() + private String _binDir + private FloatConf getFloatConf() { return FloatConf.getConf(session.config) } @@ -49,6 +52,12 @@ class FloatGridExecutor extends AbstractGridExecutor { return _floatJobs } + @Override + protected void register() { + super.register() + uploadBinDir() + } + @Override protected String getHeaderToken() { return '' @@ -58,11 +67,32 @@ class FloatGridExecutor extends AbstractGridExecutor { protected List getDirectives(TaskRun task, List initial) { log.info "[float] switch task ${task.id} to ${task.workDirStr}" floatJobs.setWorkDir(task.id, task.workDirStr) + + // go to the work directory initial << 'cd' initial << task.workDirStr + + if (needBinDir()) { + // add path to the script + initial << 'export' + initial << 'PATH=$PATH:' + _binDir + '/bin' + } return initial } + private boolean needBinDir() { + return session.binDir && !session.binDir.empty() && !session.disableRemoteBinDir + } + + private void uploadBinDir() { + // upload local binaries + if (needBinDir()) { + _binDir = getTempDir() + log.info "Uploading local `bin` ${session.binDir} to ${_binDir}/bin" + FilesEx.copyTo(session.binDir, _binDir) + } + } + private void validateTaskConf(TaskConfig config) { if (!config.nfs && !floatConf.nfs) { log.error '[float] missing "nfs": need a nfs to run float jobs'