diff --git a/h2o-py/h2o/frame.py b/h2o-py/h2o/frame.py index 76e8b08ad9a5..16de048d0716 100644 --- a/h2o-py/h2o/frame.py +++ b/h2o-py/h2o/frame.py @@ -1980,8 +1980,8 @@ def as_data_frame(self, use_pandas=True, header=True, multi_thread=False): os.remove(fileName) os.rmdir(tmpdir) elif not(can_use_datatable()): - warnings("multi_thread mode can only be used when you have datatable " - "installed.") + warnings.warn("multi_thread mode can only be used when you have datatable " + "installed. Defaults to single-thread operation.") return pandas.read_csv(StringIO(self.get_frame_data()), low_memory=False, skip_blank_lines=False) from h2o.utils.csv.readers import reader frame = [row for row in reader(StringIO(self.get_frame_data()))] diff --git a/h2o-py/tests/pyunit_utils/utilsPY.py b/h2o-py/tests/pyunit_utils/utilsPY.py index df31448a511f..8254bd0e1a2a 100644 --- a/h2o-py/tests/pyunit_utils/utilsPY.py +++ b/h2o-py/tests/pyunit_utils/utilsPY.py @@ -595,6 +595,9 @@ def javamunge(assembly, pojoname, test, compile_only=False): def install(package): subprocess.check_call([sys.executable, "-m", "pip", "install", package]) +def uninstall(package): + subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", package]) + def locate(path): """ Search for a relative path and turn it into an absolute path. diff --git a/h2o-py/tests/testdir_misc/pyunit_gh_15861_no_datatable.py b/h2o-py/tests/testdir_misc/pyunit_gh_15861_no_datatable.py new file mode 100644 index 000000000000..1acd623ea669 --- /dev/null +++ b/h2o-py/tests/testdir_misc/pyunit_gh_15861_no_datatable.py @@ -0,0 +1,28 @@ +import sys +sys.path.insert(1,"../../") +import h2o +from tests import pyunit_utils +from h2o.utils.shared_utils import (can_use_datatable) + +def test_datatable_without_datatable(): + delTable = False + if can_use_datatable(): + delTable = True + pyunit_utils.uninstall("datatable") + + try: + # should run to completion + with pyunit_utils.catch_warnings() as ws: + h2oFrame = h2o.import_file(pyunit_utils.locate("bigdata/laptop/jira/PUBDEV_5266_merge_with_string_columns/PUBDEV_5266_f1.csv")) + new_frame = h2oFrame.as_data_frame(multi_thread=True) + assert "multi_thread mode can only be used when you have datatable installed. Defaults to single-thread " \ + "operation." in str(ws[0].message) + finally: + # re-install datatable before quitting. + if delTable: + pyunit_utils.install("datatable") + +if __name__ == "__main__": + pyunit_utils.standalone_test(test_datatable_without_datatable) +else: + test_datatable_without_datatable()