Skip to content

Commit f080776

Browse files
authored
[jvm-packages] Clean external cache (dmlc#2181)
* add back train method but mark as deprecated * fix scalastyle error * change class to object in examples * fix compilation error * small fix for cleanExternalCache
1 parent 8d8cbcc commit f080776

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

jvm-packages/xgboost4j-spark/src/test/scala/ml/dmlc/xgboost4j/scala/spark/SharedSparkContext.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
package ml.dmlc.xgboost4j.scala.spark
1818

1919
import org.apache.spark.{SparkConf, SparkContext}
20-
import org.scalatest.{BeforeAndAfterAll, FunSuite}
20+
import org.scalatest.{BeforeAndAfter, BeforeAndAfterAll, FunSuite}
2121

22-
trait SharedSparkContext extends FunSuite with BeforeAndAfterAll with Serializable {
22+
trait SharedSparkContext extends FunSuite with BeforeAndAfter with BeforeAndAfterAll
23+
with Serializable {
2324

2425
@transient protected implicit var sc: SparkContext = null
2526

jvm-packages/xgboost4j-spark/src/test/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostDFSuite.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package ml.dmlc.xgboost4j.scala.spark
1818

19-
import java.io.File
19+
import java.io.{File, FileNotFoundException}
2020

2121
import scala.collection.mutable.ListBuffer
2222
import scala.io.Source
@@ -36,6 +36,10 @@ class XGBoostDFSuite extends SharedSparkContext with Utils {
3636

3737
private var trainingDF: DataFrame = null
3838

39+
after {
40+
cleanExternalCache("XGBoostDFSuite")
41+
}
42+
3943
private def buildTrainingDataframe(sparkContext: Option[SparkContext] = None): DataFrame = {
4044
if (trainingDF == null) {
4145
val rowList = loadLabelPoints(getClass.getResource("/agaricus.txt.train").getFile)
@@ -79,7 +83,6 @@ class XGBoostDFSuite extends SharedSparkContext with Utils {
7983
assert(predResultFromSeq(i)(j) === predResultsFromDF(i)(j + 1))
8084
}
8185
}
82-
cleanExternalCache("XGBoostDFSuite")
8386
}
8487

8588
test("test transformLeaf") {
@@ -125,7 +128,6 @@ class XGBoostDFSuite extends SharedSparkContext with Utils {
125128
assert(predictionDF.columns.contains("label") === true)
126129
assert(predictionDF.columns.contains("final_prediction") === true)
127130
predictionDF.show()
128-
cleanExternalCache("XGBoostDFSuite")
129131
}
130132

131133
test("test schema of XGBoostClassificationModel") {
@@ -164,7 +166,6 @@ class XGBoostDFSuite extends SharedSparkContext with Utils {
164166
assert(predictionDF.columns.contains("label") === true)
165167
assert(predictionDF.columns.contains("raw_prediction") === true)
166168
assert(predictionDF.columns.contains("final_prediction") === false)
167-
cleanExternalCache("XGBoostDFSuite")
168169
}
169170

170171
test("xgboost and spark parameters synchronize correctly") {

0 commit comments

Comments
 (0)