Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21719#discussion_r200499315
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/util/Instrumentation.scala ---
    @@ -169,22 +204,33 @@ private[spark] object Instrumentation {
         val varianceOfLabels = "varianceOfLabels"
       }
     
    +  // TODO: Remove these
       /**
        * Creates an instrumentation object for a training session.
        */
    -  def create[E <: Estimator[_]](
    -      estimator: E, dataset: Dataset[_]): Instrumentation[E] = {
    -    create[E](estimator, dataset.rdd)
    +  def create(estimator: Estimator[_], dataset: Dataset[_]): 
Instrumentation = {
    +    create(estimator, dataset.rdd)
       }
     
       /**
        * Creates an instrumentation object for a training session.
        */
    -  def create[E <: Estimator[_]](
    -      estimator: E, dataset: RDD[_]): Instrumentation[E] = {
    -    new Instrumentation[E](estimator, dataset)
    +  def create(estimator: Estimator[_], dataset: RDD[_]): Instrumentation = {
    +    new Instrumentation(estimator, dataset)
    +  }
    +  // end remove
    +
    +  def instrumented[T](body: (Instrumentation => T)): T = {
    +    val instr = new Instrumentation()
    +    Try(body(new Instrumentation())) match {
    +      case Failure(NonFatal(e)) =>
    +        instr.logFailure(e)
    +        throw e
    +      case Success(model) =>
    --- End diff --
    
    `model` -> `result`, it doesn't need to be a model


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to