Removed default use of @Output syntax.

If compile completes for QScripts, sending runtime errors during execute.
This commit is contained in:
kshakir 2012-11-29 13:31:08 -05:00
parent cf56ca3bc9
commit a6c1fcd151
3 changed files with 97 additions and 112 deletions

View File

@ -110,6 +110,9 @@ class QCommandLine extends CommandLineProgram with Logging {
* functions, and then builds and runs a QGraph based on the dependencies. * functions, and then builds and runs a QGraph based on the dependencies.
*/ */
def execute = { def execute = {
var success = false
var result = 1
try {
ClassFieldCache.parsingEngine = this.parser ClassFieldCache.parsingEngine = this.parser
if (settings.qSettings.runName == null) if (settings.qSettings.runName == null)
@ -166,7 +169,6 @@ class QCommandLine extends CommandLineProgram with Logging {
qGraph.run() qGraph.run()
val functionsAndStatus = qGraph.getFunctionsAndStatus val functionsAndStatus = qGraph.getFunctionsAndStatus
val success = qGraph.success
// walk over each script, calling onExecutionDone // walk over each script, calling onExecutionDone
for (script <- allQScripts) { for (script <- allQScripts) {
@ -180,14 +182,7 @@ class QCommandLine extends CommandLineProgram with Logging {
logger.info("Writing final jobs report...") logger.info("Writing final jobs report...")
qGraph.writeJobsReport() qGraph.writeJobsReport()
if (!success) { if (qGraph.success) {
logger.info("Done with errors")
qGraph.logFailed()
for (commandPlugin <- allCommandPlugins)
if (commandPlugin.statusMessenger != null)
commandPlugin.statusMessenger.exit("Done with errors: %s".format(qGraph.formattedStatusCounts))
1
} else {
if (settings.run) { if (settings.run) {
allQScripts.foreach(_.pushOutputs()) allQScripts.foreach(_.pushOutputs())
for (commandPlugin <- allCommandPlugins) for (commandPlugin <- allCommandPlugins)
@ -197,8 +192,21 @@ class QCommandLine extends CommandLineProgram with Logging {
commandPlugin.statusMessenger.done(allInputs, allOutputs) commandPlugin.statusMessenger.done(allInputs, allOutputs)
} }
} }
0 success = true
result = 0
} }
} finally {
if (!success) {
logger.info("Done with errors")
qGraph.logFailed()
if (settings.run) {
for (commandPlugin <- allCommandPlugins)
if (commandPlugin.statusMessenger != null)
commandPlugin.statusMessenger.exit("Done with errors: %s".format(qGraph.formattedStatusCounts))
}
}
}
result
} }
/** /**

View File

@ -124,49 +124,26 @@ trait QScript extends Logging with PrimitiveOptionConversions with StringFileCon
} }
/** /**
* Pull all remote files to the local disk. * Pull all remote files to the local disk
*/ */
def pullInputs() { def pullInputs() {
val inputs = ClassFieldCache.getFieldFiles(this, inputFields)
for (remoteFile <- filterRemoteFiles(inputs)) {
logger.info("Pulling %s from %s".format(remoteFile.getAbsolutePath, remoteFile.remoteDescription))
remoteFile.pullToLocal()
}
} }
/** /**
* Push all remote files from the local disk. * Push all remote files from the local disk
*/ */
def pushOutputs() { def pushOutputs() {
val outputs = ClassFieldCache.getFieldFiles(this, outputFields)
for (remoteFile <- filterRemoteFiles(outputs)) {
logger.info("Pushing %s to %s".format(remoteFile.getAbsolutePath, remoteFile.remoteDescription))
remoteFile.pushToRemote()
}
} }
/** /**
* List out the remote outputs * @return the inputs or null if there are no inputs
* @return the RemoteFile outputs by argument source
*/ */
def remoteInputs: Map[String, Seq[RemoteFile]] = tagMap(remoteFieldMap(inputFields)) def remoteInputs: AnyRef = null
/** /**
* List out the remote outputs * @return the outputs or null if there are no outputs
* @return the RemoteFile outputs by argument source
*/ */
def remoteOutputs: Map[String, Seq[RemoteFile]] = tagMap(remoteFieldMap(outputFields)) def remoteOutputs: AnyRef = null
private def tagMap(remoteFieldMap: Map[ArgumentSource, Seq[RemoteFile]]): Map[String, Seq[RemoteFile]] = {
remoteFieldMap.collect{ case (k, v) => ClassFieldCache.fullName(k) -> v }.toMap
}
private def remoteFieldMap(fields: Seq[ArgumentSource]): Map[ArgumentSource, Seq[RemoteFile]] = {
fields.map(field => (field -> filterRemoteFiles(ClassFieldCache.getFieldFiles(this, field)))).filter(tuple => !tuple._2.isEmpty).toMap
}
private def filterRemoteFiles(fields: Seq[File]): Seq[RemoteFile] =
fields.filter(field => field != null && field.isInstanceOf[RemoteFile]).map(_.asInstanceOf[RemoteFile])
/** The complete list of fields. */ /** The complete list of fields. */
def functionFields: Seq[ArgumentSource] = ClassFieldCache.classFunctionFields(this.getClass) def functionFields: Seq[ArgumentSource] = ClassFieldCache.classFunctionFields(this.getClass)

View File

@ -7,7 +7,7 @@ import org.broadinstitute.sting.queue.util.RemoteFile
*/ */
trait QStatusMessenger { trait QStatusMessenger {
def started() def started()
def done(inputs: Seq[Map[String, Seq[RemoteFile]]], outputs: Seq[Map[String, Seq[RemoteFile]]]) def done(inputs: Seq[_], outputs: Seq[_])
def exit(message: String) def exit(message: String)
def started(job: String) def started(job: String)