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

    https://github.com/apache/spark/pull/23263#discussion_r240003885
  
    --- Diff: mllib/src/test/scala/org/apache/spark/ml/MLEventsSuite.scala ---
    @@ -0,0 +1,199 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.ml
    +
    +import java.io.File
    +
    +import scala.collection.mutable
    +import scala.concurrent.duration._
    +
    +import org.apache.hadoop.fs.Path
    +import org.mockito.Matchers.{any, eq => meq}
    +import org.mockito.Mockito.when
    +import org.scalatest.BeforeAndAfterEach
    +import org.scalatest.concurrent.Eventually
    +import org.scalatest.mockito.MockitoSugar.mock
    +
    +import org.apache.spark.{SparkContext, SparkFunSuite}
    +import org.apache.spark.ml.param.ParamMap
    +import org.apache.spark.ml.util._
    +import org.apache.spark.scheduler.{SparkListener, SparkListenerEvent}
    +import org.apache.spark.sql._
    +import org.apache.spark.util.Utils
    +
    +
    +class MLEventsSuite
    +    extends SparkFunSuite
    +    with BeforeAndAfterEach
    +    with DefaultReadWriteTest
    +    with Eventually {
    +
    +  private var spark: SparkSession = _
    +  private var sc: SparkContext = _
    +  private var checkpointDir: String = _
    +  private var listener: SparkListener = _
    +  private val dirName: String = "pipeline"
    +  private val events = mutable.ArrayBuffer.empty[MLEvent]
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +    sc = new SparkContext("local[2]", "SparkListenerSuite")
    +    listener = new SparkListener {
    +      override def onOtherEvent(event: SparkListenerEvent): Unit = event 
match {
    +        case e: FitStart[_] => events.append(e)
    +        case e: FitEnd[_] => events.append(e)
    +        case e: TransformStart => events.append(e)
    +        case e: TransformEnd => events.append(e)
    +        case e: SaveInstanceStart if e.path.endsWith(dirName) => 
events.append(e)
    +        case e: SaveInstanceEnd if e.path.endsWith(dirName) => 
events.append(e)
    +        case _ =>
    +      }
    +    }
    +    sc.addSparkListener(listener)
    +
    +    spark = SparkSession.builder()
    +      .sparkContext(sc)
    +      .getOrCreate()
    +
    +    checkpointDir = Utils.createDirectory(tempDir.getCanonicalPath, 
"checkpoints").toString
    +    sc.setCheckpointDir(checkpointDir)
    --- End diff --
    
    Let me double check and address this while fixing the test. I just copied 
this from `MLlibTestSparkContext`.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to