Skip to content

Commit

Permalink
Committing version 0.3.4 fixing a couple of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
pditommaso committed Aug 24, 2013
1 parent 10ceb1a commit a40aace
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

apply plugin: 'groovy'
apply plugin: 'codenarc'
version = '0.3.3'
version = '0.3.4'

repositories {
flatDir(dirs: file('lib'))
Expand Down
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ NEXTFLOW CHANGE-LOG
===================

0.3.4
- Extending semnatics for method File.copyTo(source,target) so that when 'target' argument
- Extending semantic for method File.copyTo(source,target) so that when 'target' argument
is a directory, it copy the 'source' file to that folder, with the same name of the original file.
- Bug: Fixed a ClassCastEx exception when the 'bin' folder is added to the PATH
- Bug: Fixed an issue that raised an error "error=26 Text file busy" on some platforms (CentOS)

0.3.3 - 8 Aug 2013
- Added optional parameters to 'chunkLines' and 'chunkFasta' methods
Expand Down
6 changes: 3 additions & 3 deletions src/main/groovy/nextflow/Const.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ class Const {
/**
* The application version
*/
static final String APP_VER = "0.3.3"
static final String APP_VER = "0.3.4"

/**
* The app build time as linux/unix timestamp
*/
static final long APP_TIMESTAMP = 1376051851359
static final long APP_TIMESTAMP = 1377297870371

/**
* The app build number
*/
static final int APP_BUILDNUM = 752
static final int APP_BUILDNUM = 763

/**
* The date time formatter string
Expand Down
17 changes: 9 additions & 8 deletions src/main/groovy/nextflow/executor/LocalExecutor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class LocalExecutor extends AbstractExecutor {

private static final COMMAND_OUT_FILENAME = '.command.out'

private static final COMMAND_RUNNER_FILENAME = '.command.run'
private static final COMMAND_BASH_FILENAME = '.command.sh'

private static final COMMAND_ENV_FILENAME = '.command.env'

private static final COMMAND_SCRIPT_FILENAME = '.command.sh'
private static final COMMAND_SCRIPT_FILENAME = '.command.run'


/**
Expand All @@ -64,22 +64,23 @@ class LocalExecutor extends AbstractExecutor {
/*
* save the main script file
*/
def scriptStr = task.processor.normalizeScript(task.script.toString())
def scriptFile = new File(scratch, COMMAND_SCRIPT_FILENAME)
scriptFile.text = task.processor.normalizeScript(task.script.toString())
scriptFile.text = scriptStr
def interpreter = task.processor.fetchInterpreter(scriptStr)

/*
* create the runner script which will launch the script
*/
def runnerText = """
source ${COMMAND_ENV_FILENAME}
chmod +x ${COMMAND_SCRIPT_FILENAME}
./${COMMAND_SCRIPT_FILENAME}
source $COMMAND_ENV_FILENAME
$interpreter $COMMAND_SCRIPT_FILENAME
"""
def runnerFile = new File(scratch, COMMAND_RUNNER_FILENAME)
def runnerFile = new File(scratch, COMMAND_BASH_FILENAME)
runnerFile.text = task.processor.normalizeScript(runnerText)

// the cmd list to launch it
List cmd = new ArrayList(taskConfig.shell ?: 'bash' as List ) << COMMAND_RUNNER_FILENAME
List cmd = new ArrayList(taskConfig.shell ?: 'bash' as List ) << COMMAND_BASH_FILENAME
log.trace "Launch cmd line: ${cmd.join(' ')}"

/*
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/nextflow/processor/MergeTaskProcessor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class MergeTaskProcessor extends TaskProcessor {
scriptClosure.setResolveStrategy(Closure.DELEGATE_FIRST)

def commandToRun = normalizeScript(scriptClosure.call()?.toString())
def interpreter = fetchInterpreter(commandToRun)

/*
* create a unique hash-code for this task run and save it into a list
Expand All @@ -137,7 +138,6 @@ class MergeTaskProcessor extends TaskProcessor {
def scriptName = ".merge_command.sh.${index.toString().padLeft(4,'0')}"
def scriptFile = new File(mergeTempFolder, scriptName)
scriptFile.text = commandToRun
scriptFile.setExecutable(true)

// the command to launch this command
def scriptCommand = scriptFile.absolutePath
Expand All @@ -153,7 +153,7 @@ class MergeTaskProcessor extends TaskProcessor {
}

// create a unique script collecting all the commands
mergeScript << scriptCommand << '\n'
mergeScript << interpreter << ' ' << scriptCommand << '\n'

}

Expand Down
10 changes: 10 additions & 0 deletions src/main/groovy/nextflow/processor/TaskProcessor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ abstract class TaskProcessor {
return result.toString()
}

def String fetchInterpreter( String script ) {
assert script != null

if( script[0] == '#' && script[1] == '!') {
return script.readLines()[0].substring(2)
}

return null
}

/**
* Wraps the target method by a closure declaring as many arguments as many are the user declared inputs
* object.
Expand Down
29 changes: 25 additions & 4 deletions src/test/groovy/nextflow/processor/TaskProcessorTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TaskProcessorTest extends Specification {
when:
def session = new Session([env: [X:"1", Y:"2"]])
session.setBaseDir(home)
def processor = new DummyProcessor(new NopeExecutor(), session, new DummyScript(), new TaskConfig(), {})
def processor = new DummyProcessor(new NopeExecutor(), session, new TaskConfig())
def builder = new ProcessBuilder()
builder.environment().putAll( processor.getProcessEnvironment() )

Expand All @@ -53,7 +53,7 @@ class TaskProcessorTest extends Specification {
when:
session = new Session([env: [X:"1", Y:"2", PATH:'/some']])
session.setBaseDir(home)
processor = new DummyProcessor(new NopeExecutor(), session, new DummyScript(), new TaskConfig(), {})
processor = new DummyProcessor(new NopeExecutor(), session, new TaskConfig())
builder = new ProcessBuilder()
builder.environment().putAll( processor.getProcessEnvironment() )

Expand All @@ -69,11 +69,32 @@ class TaskProcessorTest extends Specification {

}

def testFetchInterpreter() {

when:
def processor = new DummyProcessor(new NopeExecutor(), new Session(), new TaskConfig())
def script =
'''
#!/bin/perl
do this
do that
'''
def i = processor.fetchInterpreter(script.stripIndent().trim())
then:
i == '/bin/perl'

when:
processor = new DummyProcessor(new NopeExecutor(), new Session(), new TaskConfig())
i = processor.fetchInterpreter('do this')
then:
i == null
}


static class DummyProcessor extends TaskProcessor {

DummyProcessor(AbstractExecutor executor, Session session, BaseScript script, TaskConfig taskConfig, Closure taskBlock) {
super(executor, session, script, taskConfig, taskBlock)
DummyProcessor(AbstractExecutor executor, Session session, TaskConfig taskConfig) {
super(executor, session, new DummyScript(), taskConfig, {})
}

@Override
Expand Down

0 comments on commit a40aace

Please sign in to comment.