Skip to content

Commit

Permalink
fix metric class name
Browse files Browse the repository at this point in the history
  • Loading branch information
gerashegalov committed Aug 7, 2019
1 parent c1dd0f5 commit ce76d38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,9 @@ case object ModelSelectorSummary {
*/
private[selector] def evalMetFromJson(className: String, json: String): Try[EvaluationMetrics] = {
def error(c: Class[_], t: Throwable): Try[MultiMetrics] = Failure[MultiMetrics] {
new IllegalArgumentException(
s"""Could not extract metrics of type ${classOf[MultiMetrics]}
|from:$json""".stripMargin, t)
new IllegalArgumentException(s"Could not extract metrics of type $c from: $json", t)
}

ReflectionUtils.classForName(className) match {
case n if n == classOf[MultiMetrics] =>
JsonUtils.fromString[Map[String, Map[String, Any]]](json).map{ d =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class ModelSelectorSummaryTest extends FlatSpec with TestSparkContext {
val thr = intercept[IllegalArgumentException](ModelSelectorSummary.evalMetFromJson(
classOf[MultiClassificationMetrics].getName, corruptJson).get)

thr.getMessage should startWith ("Could not extract metrics of type class " +
"com.salesforce.op.evaluators.MultiClassificationMetrics from: {")

thr.getCause.getMessage shouldEqual "Unsupported format. Supported formats: json, yaml"
}
}

0 comments on commit ce76d38

Please sign in to comment.