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

    https://github.com/apache/spark/pull/9749#discussion_r45005571
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/util/DefaultReadWriteTest.scala ---
    @@ -64,6 +66,47 @@ trait DefaultReadWriteTest extends TempDirectory { self: 
Suite =>
         assert(another.uid === instance.uid)
         another
       }
    +
    +  /**
    +   * Default test for Estimator, Model pairs:
    +   *  - Explicitly set Params, and train model
    +   *  - Test save/load using [[testDefaultReadWrite()]] on Estimator and 
Model
    +   *  - Check Params on Estimator and Model
    +   * @param estimator  Estimator to test
    +   * @param dataset  Dataset to pass to [[Estimator.fit()]]
    +   * @param testParams  Set of [[Param]] values to set in estimator
    +   * @param checkModelData  Method which takes the original and loaded 
[[Model]] and compares their
    +   *                        data.  This method does not need to check 
[[Param]] values.
    +   * @tparam E  Type of [[Estimator]]
    +   * @tparam M  Type of [[Model]] produced by estimator
    +   */
    +  def testEstimatorAndModelReadWrite[E <: Estimator[M] with Writable, M <: 
Model[M] with Writable](
    +      estimator: E,
    +      dataset: DataFrame,
    +      testParams: Map[String, Any],
    +      checkModelData: (M, M) => Unit): Unit = {
    +    // Set some Params to make sure set Params are serialized.
    +    testParams.foreach { case (p, v) =>
    +      estimator.set(estimator.getParam(p), v)
    +    }
    +    val model = estimator.fit(dataset)
    +
    +    // Test Estimator save/load
    +    val estimator2 = testDefaultReadWrite(estimator)
    +    testParams.foreach { case (p, v) =>
    +      val param = estimator.getParam(p)
    +      assert(estimator.get(param).get === estimator2.get(param).get)
    +    }
    +
    +    deleteTempDir()
    --- End diff --
    
    Question: Am I right that this is blocking and not risking flakiness?  I'm 
guessing based on 
[https://github.com/apache/spark/blob/fd14936be7beff543dbbcf270f2f9749f7a803c4/core/src/main/scala/org/apache/spark/util/Utils.scala#L889]
 being synchronized.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to