[jvm-packages] logging version number (#4271)
* print version number * add property file
This commit is contained in:
parent
8eab966998
commit
45c89a6792
@ -212,6 +212,12 @@
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.scalastyle</groupId>
|
||||
|
||||
@ -18,6 +18,7 @@ package ml.dmlc.xgboost4j.scala.spark
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.util.Properties
|
||||
|
||||
import scala.collection.mutable.ListBuffer
|
||||
import scala.collection.{AbstractIterator, mutable}
|
||||
@ -31,7 +32,7 @@ import org.apache.commons.io.FileUtils
|
||||
import org.apache.commons.logging.LogFactory
|
||||
|
||||
import org.apache.spark.rdd.RDD
|
||||
import org.apache.spark.{SparkContext, SparkParallelismTracker, TaskContext}
|
||||
import org.apache.spark.{SparkContext, SparkException, SparkParallelismTracker, TaskContext}
|
||||
import org.apache.spark.sql.{DataFrame, SparkSession}
|
||||
import org.apache.spark.storage.StorageLevel
|
||||
|
||||
@ -386,7 +387,7 @@ object XGBoost extends Serializable {
|
||||
hasGroup: Boolean = false,
|
||||
evalSetsMap: Map[String, RDD[XGBLabeledPoint]] = Map()):
|
||||
(Booster, Map[String, Array[Float]]) = {
|
||||
logger.info(s"XGBoost training with parameters:\n${params.mkString("\n")}")
|
||||
logger.info(s"Running XGBoost ${spark.VERSION} with parameters:\n${params.mkString("\n")}")
|
||||
val (nWorkers, round, _, _, _, _, trackerConf, timeoutRequestWorkers,
|
||||
checkpointPath, checkpointInterval) = parameterFetchAndValidation(params,
|
||||
trainingData.sparkContext)
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (c) 2014 by Contributors
|
||||
|
||||
Licensed 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 ml.dmlc.xgboost4j.scala
|
||||
|
||||
import java.util.Properties
|
||||
|
||||
import org.apache.spark.SparkException
|
||||
|
||||
package object spark {
|
||||
private def loadVersionInfo(): String = {
|
||||
val versionResourceFile = Thread.currentThread().getContextClassLoader.getResourceAsStream(
|
||||
"xgboost4j-version.properties")
|
||||
try {
|
||||
val unknownProp = "<unknown>"
|
||||
val props = new Properties()
|
||||
props.load(versionResourceFile)
|
||||
props.getProperty("version", unknownProp)
|
||||
} catch {
|
||||
case e: Exception =>
|
||||
throw new SparkException("Error loading properties from xgboost4j-version.properties", e)
|
||||
} finally {
|
||||
if (versionResourceFile != null) {
|
||||
try {
|
||||
versionResourceFile.close()
|
||||
} catch {
|
||||
case e: Exception =>
|
||||
throw new SparkException("Error closing xgboost4j version resource stream", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val VERSION: String = loadVersionInfo()
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
version=${project.version}
|
||||
Loading…
x
Reference in New Issue
Block a user