Example #1
0
def consistency_check():

    try:
        small = pyunit_utils.locate("h2o-py/demos/citi_bike_small.ipynb")
    except ValueError:
        small = pyunit_utils.locate(
            "h2o-py/demos/citi_bike_small_NOPASS.ipynb")

    try:
        large = pyunit_utils.locate("h2o-py/demos/citi_bike_large.ipynb")
    except ValueError:
        large = pyunit_utils.locate(
            "h2o-py/demos/citi_bike_large_NOPASS.ipynb")

    results_dir = pyunit_utils.locate("results")
    s = os.path.join(results_dir,
                     os.path.basename(small).split('.')[0] + ".py")
    l = os.path.join(results_dir,
                     os.path.basename(large).split('.')[0] + ".py")

    from tests import pydemo_utils
    pydemo_utils.ipy_notebook_exec(small, save_and_norun=s)
    pydemo_utils.ipy_notebook_exec(large, save_and_norun=l)

    small_list = list(open(s, 'r'))
    large_list = list(open(l, 'r'))

    for s, l in zip(small_list, large_list):
        if s != l:
            assert s == "data = h2o.import_file(path=small_test)\n" and \
                   l != "data = h2o.import_file(path=large_test)\n", \
                "This difference is not allowed between the small and large citibike demos.\nCitibike small: {0}" \
                "Citibike large: {1}".format(s,l)
def consistency_check():

    try:
        small = pyunit_utils.locate("h2o-py/demos/citi_bike_small.ipynb")
    except ValueError:
        small = pyunit_utils.locate("h2o-py/demos/citi_bike_small_NOPASS.ipynb")

    try:
        large = pyunit_utils.locate("h2o-py/demos/citi_bike_large.ipynb")
    except ValueError:
        large = pyunit_utils.locate("h2o-py/demos/citi_bike_large_NOPASS.ipynb")

    results_dir = pyunit_utils.locate("results")
    s = os.path.join(results_dir, os.path.basename(small).split('.')[0]+".py")
    l = os.path.join(results_dir, os.path.basename(large).split('.')[0]+".py")

    from tests import pydemo_utils
    pydemo_utils.ipy_notebook_exec(small, save_and_norun = s)
    pydemo_utils.ipy_notebook_exec(large, save_and_norun = l)

    small_list = list(open(s, 'r'))
    large_list = list(open(l, 'r'))

    for s, l in zip(small_list, large_list):
        if s != l:
            assert s == "data = h2o.import_file(path=small_test)\n" and \
                   l != "data = h2o.import_file(path=large_test)\n", \
                "This difference is not allowed between the small and large citibike demos.\nCitibike small: {0}" \
                "Citibike large: {1}".format(s,l)
def h2o_test_setup(sys_args):
    h2o_py_dir = os.path.realpath(
        os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
    h2o_docs_dir = os.path.realpath(
        os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..",
                     "h2o-docs"))

    parse_args(sys_args)

    sys.path.insert(1, h2o_py_dir)
    import h2o
    from tests import pyunit_utils, pydemo_utils, pybooklet_utils

    for pkg in (pyunit_utils, pybooklet_utils):
        setattr(pkg, '__on_hadoop__', _ON_HADOOP_)
        setattr(pkg, '__hadoop_namenode__', _HADOOP_NAMENODE_)
        setattr(pkg, '__test_name__', _TEST_NAME_)
        setattr(pkg, '__results_dir__', _RESULTS_DIR_)

    if _IS_PYUNIT_ or _IS_IPYNB_ or _IS_PYBOOKLET_ or _IS_PYDEMO_:
        pass
    else:
        raise (
            EnvironmentError,
            "Unrecognized test type. Must be of type ipynb, pydemo, pyunit, or pybooklet, but got: "
            "{0}".format(_TEST_NAME_))

    print("[{0}] {1}\n".format(
        strftime("%Y-%m-%d %H:%M:%S", gmtime()),
        "Connect to h2o on IP: {0} PORT: {1}".format(_H2O_IP_, _H2O_PORT_)))
    auth = None
    if _LDAP_USER_NAME_ is not None and _LDAP_PASSWORD_ is not None:
        auth = (_LDAP_USER_NAME_, _LDAP_PASSWORD_)
    h2o.connect(ip=_H2O_IP_, port=_H2O_PORT_, verbose=False, auth=auth)
    h2o.utils.config.H2OConfigReader.get_config(
    )["general.allow_breaking_changes"] = True

    #rest_log = os.path.join(_RESULTS_DIR_, "rest.log")
    #h2o.start_logging(rest_log)
    #print "[{0}] {1}\n".format(strftime("%Y-%m-%d %H:%M:%S", gmtime()), "Started rest logging in: {0}".format(rest_log))

    h2o.log_and_echo(
        "------------------------------------------------------------")
    h2o.log_and_echo("")
    h2o.log_and_echo("STARTING TEST: " + _TEST_NAME_)
    h2o.log_and_echo("")
    h2o.log_and_echo(
        "------------------------------------------------------------")

    h2o.remove_all()

    if _IS_IPYNB_: pydemo_utils.ipy_notebook_exec(_TEST_NAME_)
    elif _IS_PYUNIT_: pyunit_utils.pyunit_exec(_TEST_NAME_)
    elif _IS_PYBOOKLET_: pybooklet_utils.pybooklet_exec(_TEST_NAME_)
    elif _IS_PYDEMO_: pydemo_utils.pydemo_exec(_TEST_NAME_)
Example #4
0
def h2o_test_setup(sys_args):
    h2o_py_dir = os.path.realpath(
        os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
    h2o_docs_dir = os.path.realpath(
        os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..",
                     "h2o-docs"))

    parse_args(sys_args)

    sys.path.insert(1, h2o_py_dir)
    import h2o
    from tests import pyunit_utils, pydemo_utils, pybooklet_utils

    set_pyunit_pkg_attrs(pyunit_utils)
    set_pybooklet_pkg_attrs(pybooklet_utils)

    if _IS_PYUNIT_ or _IS_IPYNB_ or _IS_PYBOOKLET_ or _IS_PYDEMO_:
        pass
    else:
        raise (
            EnvironmentError,
            "Unrecognized test type. Must be of type ipynb, pydemo, pyunit, or pybooklet, but got: "
            "{0}".format(_TEST_NAME_))

    print("[{0}] {1}\n".format(
        strftime("%Y-%m-%d %H:%M:%S", gmtime()),
        "Connect to h2o on IP: {0} PORT: {1}".format(_H2O_IP_, _H2O_PORT_)))
    h2o.init(ip=_H2O_IP_,
             port=_H2O_PORT_,
             strict_version_check=False,
             force_connect=_FORCE_CONNECT_)
    h2o.utils.config.H2OConfigReader.get_config(
    )["general.allow_breaking_changes"] = True

    #rest_log = os.path.join(_RESULTS_DIR_, "rest.log")
    #h2o.start_logging(rest_log)
    #print "[{0}] {1}\n".format(strftime("%Y-%m-%d %H:%M:%S", gmtime()), "Started rest logging in: {0}".format(rest_log))

    h2o.log_and_echo(
        "------------------------------------------------------------")
    h2o.log_and_echo("")
    h2o.log_and_echo("STARTING TEST: " + _TEST_NAME_)
    h2o.log_and_echo("")
    h2o.log_and_echo(
        "------------------------------------------------------------")

    h2o.remove_all()

    if _IS_IPYNB_: pydemo_utils.ipy_notebook_exec(_TEST_NAME_)
    elif _IS_PYUNIT_: pyunit_utils.pyunit_exec(_TEST_NAME_)
    elif _IS_PYBOOKLET_: pybooklet_utils.pybooklet_exec(_TEST_NAME_)
    elif _IS_PYDEMO_: pydemo_utils.pydemo_exec(_TEST_NAME_)
Example #5
0
def h2o_test_setup(sys_args):
    h2o_py_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)),".."))
    h2o_docs_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)),"..","..","h2o-docs"))

    parse_args(sys_args)

    sys.path.insert(1, h2o_py_dir)
    import h2o
    from tests import pyunit_utils, pydemo_utils, pybooklet_utils

    for pkg in (pyunit_utils, pybooklet_utils):
        setattr(pkg, '__on_hadoop__', _ON_HADOOP_)
        setattr(pkg, '__hadoop_namenode__', _HADOOP_NAMENODE_)
        setattr(pkg, '__test_name__', _TEST_NAME_)
        setattr(pkg, '__results_dir__', _RESULTS_DIR_)

    if _IS_PYUNIT_ or _IS_IPYNB_ or _IS_PYBOOKLET_ or _IS_PYDEMO_:
        pass
    else:
        raise(EnvironmentError, "Unrecognized test type. Must be of type ipynb, pydemo, pyunit, or pybooklet, but got: "
                                "{0}".format(_TEST_NAME_))

    print("[{0}] {1}\n".format(strftime("%Y-%m-%d %H:%M:%S", gmtime()), "Connect to h2o on IP: {0} PORT: {1}".format(_H2O_IP_, _H2O_PORT_)))
    auth = None
    if _LDAP_USER_NAME_ is not None and _LDAP_PASSWORD_ is not None:
        auth = (_LDAP_USER_NAME_, _LDAP_PASSWORD_)
    elif _KERB_PRINCIPAL_ is not None:
        from h2o.auth import SpnegoAuth
        auth = SpnegoAuth(service_principal=_KERB_PRINCIPAL_)
    h2o.connect(ip=_H2O_IP_, port=_H2O_PORT_, verbose=False, auth=auth, **_H2O_EXTRA_CONNECT_ARGS_)
    h2o.utils.config.H2OConfigReader.get_config()["general.allow_breaking_changes"] = True

    #rest_log = os.path.join(_RESULTS_DIR_, "rest.log")
    #h2o.start_logging(rest_log)
    #print "[{0}] {1}\n".format(strftime("%Y-%m-%d %H:%M:%S", gmtime()), "Started rest logging in: {0}".format(rest_log))

    h2o.log_and_echo("------------------------------------------------------------")
    h2o.log_and_echo("")
    h2o.log_and_echo("STARTING TEST: " + _TEST_NAME_)
    h2o.log_and_echo("")
    h2o.log_and_echo("------------------------------------------------------------")

    h2o.remove_all()

    if _IS_IPYNB_:       pydemo_utils.ipy_notebook_exec(_TEST_NAME_)
    elif _IS_PYUNIT_:    pyunit_utils.pyunit_exec(_TEST_NAME_)
    elif _IS_PYBOOKLET_: pybooklet_utils.pybooklet_exec(_TEST_NAME_)
    elif _IS_PYDEMO_:    pydemo_utils.pydemo_exec(_TEST_NAME_)
Example #6
0
def h2o_test_setup(sys_args):
    h2o_py_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)),".."))
    h2o_docs_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)),"..","..","h2o-docs"))

    parse_args(sys_args)

    sys.path.insert(1, h2o_py_dir)
    import h2o
    from tests import pyunit_utils, pydemo_utils, pybooklet_utils

    set_pyunit_pkg_attrs(pyunit_utils)
    set_pybooklet_pkg_attrs(pybooklet_utils)

    if _IS_PYUNIT_ or _IS_IPYNB_ or _IS_PYBOOKLET_:
        pass
    elif _IS_PYDEMO_:
        raise(NotImplementedError, "pydemos are not supported at this time")
    else:
        raise(EnvironmentError, "Unrecognized test type. Must be of type ipynb, pydemo, pyunit, or pybooklet, but got: "
                                "{0}".format(_TEST_NAME_))

    print "[{0}] {1}\n".format(strftime("%Y-%m-%d %H:%M:%S", gmtime()), "Connect to h2o on IP: {0} PORT: {1}"
                                                                        "".format(_H2O_IP_, _H2O_PORT_))
    h2o.init(ip=_H2O_IP_, port=_H2O_PORT_, strict_version_check=False)

    #rest_log = os.path.join(_RESULTS_DIR_, "rest.log")
    #h2o.start_logging(rest_log)
    #print "[{0}] {1}\n".format(strftime("%Y-%m-%d %H:%M:%S", gmtime()), "Started rest logging in: {0}".format(rest_log))

    h2o.log_and_echo("------------------------------------------------------------")
    h2o.log_and_echo("")
    h2o.log_and_echo("STARTING TEST: " + _TEST_NAME_)
    h2o.log_and_echo("")
    h2o.log_and_echo("------------------------------------------------------------")

    h2o.remove_all()

    if _IS_IPYNB_:       pydemo_utils.ipy_notebook_exec(_TEST_NAME_)
    elif _IS_PYUNIT_:    pyunit_utils.pyunit_exec(_TEST_NAME_)
    elif _IS_PYBOOKLET_: pybooklet_utils.pybooklet_exec(_TEST_NAME_)