Skip to content

Commit

Permalink
fix: fix library checking while installing library on databricks clus…
Browse files Browse the repository at this point in the history
…ter (#1488)

* fix library checking while installing library on databricks cluster

* fix: fix PR template typo

* fix name
  • Loading branch information
serena-ruan committed Apr 24, 2022
1 parent cd2c8f0 commit 918d92c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ _Briefly describe the changes included in this Pull Request._

_Describe what tests have you performed to validate your changes before submitting the Pull Request. Use 'N/A' if not applicable._

# Dependency chances
# Dependency changes

_If you needed to make any chances to dependencies of this project, please describe them here._
_If you needed to make any changes to dependencies of this project, please describe them here._
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DatabricksTests extends TestBase {
println("Installing libraries")
installLibraries(clusterId)
tryWithRetries(Seq.fill(60 * 3)(1000).toArray) { () =>
assert(isClusterActive(clusterId))
assert(areLibrariesInstalled(clusterId))
}
println(s"Creating folder $Folder")
workspaceMkDir(Folder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ object DatabricksUtilities extends HasHttpClient {
state == "RUNNING"
}

def areLibrariesInstalled(clusterId: String): Boolean = {
val clusterObj = databricksGet(s"libraries/cluster-status?cluster_id=$clusterId")
val libraryStatuses = clusterObj.asInstanceOf[JsObject].fields("library_statuses")
.asInstanceOf[JsArray].elements
if (libraryStatuses.exists(_.select[String]("status") == "FAILED")) {
val error = libraryStatuses.filter(_.select[String]("status") == "FAILED").toJson.compactPrint
throw new RuntimeException(s"Library Installation Failure: $error")
}
libraryStatuses.forall(_.select[String]("status") == "INSTALLED")
}

private def getRunStatuses(runId: Int): (String, Option[String]) = {
val runObj = databricksGet(s"jobs/runs/get?run_id=$runId")
val stateObj = runObj.select[JsObject]("state")
Expand Down

0 comments on commit 918d92c

Please sign in to comment.