Gather the log files before the actual outputs and mark the log files gatherers as intermediates.

Since the outputs will only be gathered iff the logs were gathered this allows the job name to change without causing SG to re-run.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5285 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
kshakir 2011-02-21 22:04:35 +00:00
parent 1a5d296737
commit dee130ad1b
4 changed files with 29 additions and 4 deletions

View File

@ -484,7 +484,7 @@ class QGraph extends Logging {
} }
private def failedDescription(failed: FunctionEdge) = { private def failedDescription(failed: FunctionEdge) = {
var description = new StringBuilder val description = new StringBuilder
if (settings.retries > 0) if (settings.retries > 0)
description.append("Attempt %d of %d.%n".format(failed.retries + 1, settings.retries + 1)) description.append("Attempt %d of %d.%n".format(failed.retries + 1, settings.retries + 1))
description.append(failed.function.description) description.append(failed.function.description)
@ -749,7 +749,7 @@ class QGraph extends Logging {
if (running && !settings.keepIntermediates && success) { if (running && !settings.keepIntermediates && success) {
logger.info("Deleting intermediate files.") logger.info("Deleting intermediate files.")
traverseFunctions(edge => { traverseFunctions(edge => {
if (edge.function.isIntermediate) { if (edge.function.isIntermediate && edge.function.deleteIntermediateOutputs) {
logger.debug("Deleting intermediates:" + edge.function.description) logger.debug("Deleting intermediates:" + edge.function.description)
edge.function.deleteOutputs() edge.function.deleteOutputs()
} }

View File

@ -55,6 +55,12 @@ trait QFunction extends Logging {
*/ */
var isIntermediate = false var isIntermediate = false
/**
* If true and isIntermediate is true, the files listed
* via outputs will deleted after the command completes.
*/
var deleteIntermediateOutputs = true
/** /**
* Copies settings from this function to another function. * Copies settings from this function to another function.
* @param function QFunction to copy values to. * @param function QFunction to copy values to.
@ -70,6 +76,7 @@ trait QFunction extends Logging {
function.jobRestartable = this.jobRestartable function.jobRestartable = this.jobRestartable
function.updateJobRun = this.updateJobRun function.updateJobRun = this.updateJobRun
function.isIntermediate = this.isIntermediate function.isIntermediate = this.isIntermediate
function.deleteIntermediateOutputs = this.deleteIntermediateOutputs
} }
/** File to redirect any output. Defaults to <jobName>.out */ /** File to redirect any output. Defaults to <jobName>.out */

View File

@ -13,6 +13,9 @@ trait GatherFunction extends QFunction {
@Input(doc="Parts to gather back into the original output") @Input(doc="Parts to gather back into the original output")
var gatherParts: List[File] = Nil var gatherParts: List[File] = Nil
@Input(doc="Other log files that will be gathered before this output", required=false)
var originalLogFiles: List[File] = Nil
@Output(doc="The original output of the scattered function") @Output(doc="The original output of the scattered function")
var originalOutput: File = _ var originalOutput: File = _

View File

@ -82,6 +82,11 @@ trait ScatterGatherableFunction extends CommandLineFunction {
// Ask the scatter function how many clones to create. // Ask the scatter function how many clones to create.
val numClones = scatterFunction.scatterCount val numClones = scatterFunction.scatterCount
// List of the log files that are output by this function.
var logFiles = List(this.jobOutputFile)
if (this.jobErrorFile != null)
logFiles :+= this.jobErrorFile
// Create the gather functions for each output field // Create the gather functions for each output field
var gatherFunctions = Map.empty[ArgumentSource, GatherFunction] var gatherFunctions = Map.empty[ArgumentSource, GatherFunction]
var gatherOutputs = Map.empty[ArgumentSource, File] var gatherOutputs = Map.empty[ArgumentSource, File]
@ -92,12 +97,23 @@ trait ScatterGatherableFunction extends CommandLineFunction {
this.copySettingsTo(gatherFunction) this.copySettingsTo(gatherFunction)
gatherFunction.addOrder = this.addOrder :+ gatherAddOrder gatherFunction.addOrder = this.addOrder :+ gatherAddOrder
gatherFunction.commandDirectory = this.scatterGatherTempDir("gather-" + gatherField.field.getName) gatherFunction.commandDirectory = this.scatterGatherTempDir("gather-" + gatherField.field.getName)
gatherFunction.originalOutput = this.getFieldFile(gatherField) gatherFunction.originalOutput = gatherOutput
initGatherFunction(gatherFunction, gatherField) initGatherFunction(gatherFunction, gatherField)
functions :+= gatherFunction functions :+= gatherFunction
gatherFunctions += gatherField -> gatherFunction gatherFunctions += gatherField -> gatherFunction
gatherOutputs += gatherField -> gatherOutput gatherOutputs += gatherField -> gatherOutput
gatherAddOrder += 1 gatherAddOrder += 1
// If this is a gather for a log file, make the gather intermediate just in case the log file name changes
// Otherwise have the regular output function wait on the log files to gather
if (isLogFile(gatherOutput)) {
gatherFunction.isIntermediate = true
// Only delete the log files if the original function is an intermediate
// and the intermediate files are supposed to be deleted
gatherFunction.deleteIntermediateOutputs = this.isIntermediate && this.deleteIntermediateOutputs
} else {
gatherFunction.originalLogFiles = logFiles
}
} }
// Create the clone functions for running the parallel jobs // Create the clone functions for running the parallel jobs
@ -122,7 +138,6 @@ trait ScatterGatherableFunction extends CommandLineFunction {
// Allow the script writer to change the paths to the files. // Allow the script writer to change the paths to the files.
initCloneFunction(cloneFunction, i) initCloneFunction(cloneFunction, i)
// If the command directory is relative, insert the run directory ahead of it. // If the command directory is relative, insert the run directory ahead of it.
cloneFunction.absoluteCommandDirectory() cloneFunction.absoluteCommandDirectory()