diff --git a/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala b/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala index 093741b5d..73ab7c366 100644 --- a/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala +++ b/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala @@ -40,6 +40,7 @@ trait QJobReport extends Logging { self: QFunction => protected var reportGroup: String = null + protected var userReportFeatures: Map[String, String] = Map() protected var reportFeatures: Map[String, String] = Map() protected var reportEnabled: Boolean = true @@ -49,7 +50,7 @@ trait QJobReport extends Logging { def setRunInfo(info: JobRunInfo) { //logger.info("info " + info) - reportFeatures = Map( + val runtimeFeatures = Map( "iteration" -> 1, "analysisName" -> getReportGroup, "jobName" -> QJobReport.workAroundSameJobNames(this), @@ -59,36 +60,39 @@ trait QJobReport extends Logging { "doneTime" -> info.getDoneTime.getTime, "formattedStartTime" -> info.getFormattedStartTime, "formattedDoneTime" -> info.getFormattedDoneTime, - "runtime" -> info.getRuntimeInMs).mapValues((x:Any) => if (x != null) x.toString else "null") ++ reportFeatures + "runtime" -> info.getRuntimeInMs).mapValues((x:Any) => if (x != null) x.toString else "null") + reportFeatures = runtimeFeatures ++ userReportFeatures // note -- by adding reportFeatures second we override iteration // (or any other binding) with the user provided value } /** The report Group is the analysis name transform to only contain valid GATKReportTable characters */ def getReportGroup = self.analysisName.replaceAll(GATKReportTable.INVALID_TABLE_NAME_REGEX, "_") - def getReportFeatures = reportFeatures - def getReportFeatureNames: Seq[String] = getReportFeatures.keys.toSeq + def getReportFeatureNames: Seq[String] = reportFeatures.keys.toSeq def getReportFeature(key: String): String = { - getReportFeatures.get(key) match { + reportFeatures.get(key) match { case Some(x) => x - case None => throw new RuntimeException("Get called with key %s but no value was found".format(key)) + case None => + logger.warn("getReportFeature called with key %s but no value was found for group %s. This can be caused by adding user-defined job features to a job with a generic name used elsewhere in the Queue script. To fix the problem make sure that each group of commands with user-specific features has a unique analysisName".format(key, reportGroup)) + "NA" } } def getReportName: String = getReportFeature("jobName") def configureJobReport(features: Map[String, Any]) { - this.reportFeatures = features.mapValues(_.toString) + this.userReportFeatures = features.mapValues(_.toString) } def addJobReportBinding(key: String, value: Any) { - this.reportFeatures += (key -> value.toString) + this.userReportFeatures += (key -> value.toString) } // copy the QJobReport information -- todo : what's the best way to do this? override def copySettingsTo(function: QFunction) { self.copySettingsTo(function) + function.userReportFeatures = this.userReportFeatures function.reportFeatures = this.reportFeatures } }