Acumos H2O Model Builder Python Developer Guide

This H2O Model builder builds H2O models given a dataset which is a location to read the data to train the model as well as a validation dataset. This service has a dependency on dataset service and dataset service for this operation of building the model. Once the model is built, the user may upload the model to model-management using the export method so this service also has a dependency on model-management service.

This service also uses memcache to store model generation history information as building the model happens asynchronously.

The main class to start this service is /h2o-model-builder/microservice_flask.py

The command line interface gives options to run the application. Type help for a list of available options. > microservice_flask.py help usage: microservice_flask.py [-h] [–host HOST] [–settings SETTINGS] [–port PORT]

By default without adding arguments the swagger interface should be available at: http://localhost:8061/v2/

Testing

The only prerequisite for running unit testing is installing python and tox. It is recommended to use a virtual environment for running any python application. If using a virtual environment make sure to run “pip install tox” to install it

For testing the actual service, memcache will need to be running on the system.
https://memcached.org/

We use a combination of ‘tox’, ‘pytest’, and ‘flake8’ to test ‘h20-model-builder’. Code which is not PEP8 compliant (aside from E501) will be considered a failing test. You can use tools like ‘autopep8’ to “clean” your code as follows:

$ pip install autopep8 pyflakes pycodestyle
$ cd h2o-model-builder
$ autopep8 -r --in-place modelbuilder

Run tox directly:

$ cd h2o-model-builder
$ tox

You can also specify certain tox environments to test:

$ tox -e py34  # only test against Python 3.4
$ tox -e flake8  # only lint code

And finally, you can run pytest directly in your environment (recommended starting place):

$ pytest
$ pytest -s   # verbose output