-
Notifications
You must be signed in to change notification settings - Fork 2k
/
pyunit_mojo_pipeline.py
39 lines (32 loc) · 1.09 KB
/
pyunit_mojo_pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""pyunit for H2OMojoPipeline.transform"""
from __future__ import print_function
import sys
sys.path.insert(1,"../../")
import h2o
import os
from h2o.pipeline import H2OMojoPipeline
from tests import pyunit_utils
def mojo_pipeline():
test_dir = os.environ.get('MOJO_PIPELINE_TEST_DIR')
if test_dir is None:
print("Test dir not configured, MOJO Pipeline test skipped")
return
if not H2OMojoPipeline.available():
print("Backend is not configured for MOJO Pipelines, MOJO Pipeline test skipped")
return
example_csv = os.path.join(test_dir, "example.csv")
mojo_file = os.path.join(test_dir, "pipeline.mojo")
example_data = h2o.import_file(example_csv)
pipeline = H2OMojoPipeline(mojo_file)
transformed = pipeline.transform(example_data)
transformed.show()
assert transformed.dim == [10, 2]
totals = transformed[0] + transformed[1]
assert totals.min() == 1
assert totals.max() == 1
if __name__ == "__main__":
pyunit_utils.standalone_test(mojo_pipeline)
else:
mojo_pipeline()