Skip to content

Commit

Permalink
[GH-32] Upload bin directory.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jealous committed Jul 12, 2023
1 parent a35634d commit 87eec32
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,6 +39,8 @@ class FloatGridExecutor extends AbstractGridExecutor {

private AtomicInteger serial = new AtomicInteger()

private String _binDir

private FloatConf getFloatConf() {
return FloatConf.getConf(session.config)
}
Expand All @@ -49,6 +52,12 @@ class FloatGridExecutor extends AbstractGridExecutor {
return _floatJobs
}

@Override
protected void register() {
super.register()
uploadBinDir()
}

@Override
protected String getHeaderToken() {
return ''
Expand All @@ -58,11 +67,32 @@ class FloatGridExecutor extends AbstractGridExecutor {
protected List<String> getDirectives(TaskRun task, List<String> 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'
Expand Down

0 comments on commit 87eec32

Please sign in to comment.