Skip to content

Commit

Permalink
added extended message to h2o.init to help user get around version mi…
Browse files Browse the repository at this point in the history
…smatch error.
  • Loading branch information
wendycwong committed Jun 29, 2023
1 parent 8923a56 commit a5310d0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
9 changes: 6 additions & 3 deletions h2o-py/h2o/backend/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,19 @@ def check_version(self, strict=False):
if build_number_h2o is None or build_number_h2o == "unknown":
message = ("Version mismatch. H2O is version {0}, but the h2o-python package is version {1}. "
"Upgrade H2O and h2o-Python to latest stable version - "
"http://h2o-release.s3.amazonaws.com/h2o/latest_stable.html"
"http://h2o-release.s3.amazonaws.com/h2o/latest_stable.html. To circumvent this error "
"message (not recommended), you can set strict_version_check=False."
).format(ver_h2o, ver_pkg)
elif build_number_h2o == "99999":
message = ("Version mismatch. H2O is version {0}, but the h2o-python package is version {1}. "
"This is a developer build, please contact your developer."
"This is a developer build, please contact your developer. To circumvent this error "
"message (not recommended), you can set strict_version_check=False."
).format(ver_h2o, ver_pkg)
else:
message = ("Version mismatch. H2O is version {0}, but the h2o-python package is version {1}. "
"Install the matching h2o-Python version from - "
"http://h2o-release.s3.amazonaws.com/h2o/{2}/{3}/index.html."
"http://h2o-release.s3.amazonaws.com/h2o/{2}/{3}/index.html. To circumvent this error "
"message (not recommended), you can set strict_version_check=False."
).format(ver_h2o, ver_pkg, branch_name_h2o, build_number_h2o)
if strict:
raise H2OConnectionError(message)
Expand Down
12 changes: 8 additions & 4 deletions h2o-r/h2o-package/R/connection.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,22 @@ h2o.init <- function(ip = "localhost", port = 54321, name = NA_character_, start

if( is.null( build_number_H2O ) ){
stop(sprintf("Version mismatch! H2O is running version %s but h2o-R package is version %s.
Upgrade H2O and R to latest stable version - https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html",
Upgrade H2O and R to latest stable version - https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html.
To circumvent this error message (not recommended), you can set strict_version_check=FALSE.",
verH2O, toString(verPkg)))
} else if (build_number_H2O =="unknown"){
stop(sprintf("Version mismatch! H2O is running version %s but h2o-R package is version %s.
Upgrade H2O and R to latest stable version - https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html",
Upgrade H2O and R to latest stable version - https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html.
To circumvent this error message (not recommended), you can set strict_version_check=FALSE.",
verH2O, toString(verPkg)))
} else if (build_number_H2O =="99999"){
stop((sprintf("Version mismatch! H2O is running version %s but h2o-R package is version %s.
This is a developer build, please contact your developer",verH2O, toString(verPkg) )))
This is a developer build, please contact your developer. To circumvent this error message (not recommended),
you can set strict_version_check=FALSE.",verH2O, toString(verPkg) )))
} else {
stop(sprintf("Version mismatch! H2O is running version %s but h2o-R package is version %s.
Install the matching h2o-R version from - https://h2o-release.s3.amazonaws.com/h2o/%s/%s/index.html",
Install the matching h2o-R version from - https://h2o-release.s3.amazonaws.com/h2o/%s/%s/index.html. To
circumvent this error message (not recommended), you can set strict_version_check=FALSE.",
verH2O, toString(verPkg),branch_name_H2O,build_number_H2O))
}
}
Expand Down
23 changes: 23 additions & 0 deletions h2o-r/tests/testdir_misc/runit_GH_6707_init_version_check.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
setwd(normalizePath(dirname(
R.utils::commandArgs(asValues = TRUE)$"f"
)))
source("../../scripts/h2o-r-test-setup.R")

h2o_init_test <- function() {
e <- tryCatch({
h2o.init(
strict_version_check = TRUE
)
}, error = function(x) x)

if (!is.null(e)) {
print(e)
err_message <- e[[1]]
if (!grepl("there is no package called ‘h2o’", err_message)) { # this error can occur for some reason. Getting around it by using this check
expect_true(grepl("To circumvent this error message (not recommended), you can set strict_version_check=False", err_message))
}
}
}

doTest("Make sure connection version mismatch error contains new error message.",
h2o_init_test)

0 comments on commit a5310d0

Please sign in to comment.