Skip to content

Commit

Permalink
fix cudf version checker
Browse files Browse the repository at this point in the history
  • Loading branch information
pxLi committed May 21, 2021
1 parent eddb8d6 commit 7a5002b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sql-plugin/src/main/scala/com/nvidia/spark/SQLPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.nvidia.spark

import com.nvidia.spark.rapids.{RapidsDriverPlugin, RapidsExecutorPlugin}

import org.apache.spark.api.plugin.{DriverPlugin, ExecutorPlugin, SparkPlugin}
import org.apache.spark.internal.Logging

Expand All @@ -27,5 +26,6 @@ import org.apache.spark.internal.Logging
*/
class SQLPlugin extends SparkPlugin with Logging {
override def driverPlugin(): DriverPlugin = new RapidsDriverPlugin

override def executorPlugin(): ExecutorPlugin = new RapidsExecutorPlugin
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,12 @@ object RapidsExecutorPlugin {
* version 7.1.1.
*/
def cudfVersionSatisfied(expected: String, actual: String): Boolean = {
val (expMajorMinor, expPatch) = expected.split('.').splitAt(2)
val (actMajorMinor, actPatch) = actual.split('.').splitAt(2)
val expHyphen = if (expected.indexOf('-') >= 0) expected.indexOf('-') else expected.length
val actHyphen = if (actual.indexOf('-') >= 0) actual.indexOf('-') else actual.length
if (actual.substring(actHyphen) != expected.substring(expHyphen)) return false

val (expMajorMinor, expPatch) = expected.substring(0, expHyphen).split('.').splitAt(2)
val (actMajorMinor, actPatch) = actual.substring(0, actHyphen).split('.').splitAt(2)
actMajorMinor.startsWith(expMajorMinor) && {
val expPatchInts = expPatch.map(_.toInt)
val actPatchInts = actPatch.map(v => Try(v.toInt).getOrElse(Int.MinValue))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class RapidsExecutorPluginSuite extends FunSuite {
assert(!RapidsExecutorPlugin.cudfVersionSatisfied("7.0.1", "7.1"))
assert(!RapidsExecutorPlugin.cudfVersionSatisfied("7.0.1", "7.1.1"))
assert(!RapidsExecutorPlugin.cudfVersionSatisfied("7.0.1", "7.0.1-special"))
assert(!RapidsExecutorPlugin.cudfVersionSatisfied("7.0.1-special", "7.0.1"))
assert(RapidsExecutorPlugin.cudfVersionSatisfied("7.0.1-special", "7.0.1-special"))
assert(!RapidsExecutorPlugin.cudfVersionSatisfied("7.0.2-special", "7.0.1-special"))
assert(RapidsExecutorPlugin.cudfVersionSatisfied("7.0.1-special", "7.0.2-special"))
assert(!RapidsExecutorPlugin.cudfVersionSatisfied("7.0.2.2.2", "7.0.2.2"))
assert(RapidsExecutorPlugin.cudfVersionSatisfied("7.0.2.2.2", "7.0.2.2.2"))
}
Expand Down

0 comments on commit 7a5002b

Please sign in to comment.