Using H2O.ai Models with Snowflake - Snowflake External Functions
=================================================================

Version:1.4.1

Requirements
------------

1. Snowflake login credentials

2. AWS access keys (access key ID and secret access key)

3. ai.h2o.mojos.jar 
   -- included in the Rest-Scorer directory

4. Driverless AI Mojo
   -- copy the mojo file in the Models directory

5. Driverless AI license
   -- provided via the partnership portal
   -- copy the license to the license.sig file in the Rest-Scorer directory

6. Java JDK 1.8
   -- execute “java -version” to verify the available JVM on your platform has JDK 1.8 installed. The output of the command should indicate JDK 1.8
   -- if the output does not show JDK 1.8, you will need to download a 1.8 JDK for your environment, the following sites provide current builds for free:
      * https://www.azul.com/downloads/zulu-community/
      * https://openjdk.java.net/install/


H2O REST Server Installation
-----------------------------

Command-line scripts are available in the Rest-Scorer directory to start and stop the H2O REST Server, they are called goServer.sh and stopServer.sh

A script called goVerifyEndpoint.sh is available to validate successful installation and correct initialization of the H2O REST SERVER and its model components.

Finally, goVerifySnowflakeConfig.sh can be used to validate server-side Snowflake configuration.

H2O REST Server config options using command line arguments (goServer.sh):
* -DServer.port -- port # on which to install H2O REST Server
  (please note: you must allow HTTP traffic on this port for your instance)
* -Dverbose -- request to see the payload and issues
   example: `curl "127.0.0.1:8080/model?name=pipeline.mojo&verbose=true&row=5000,%2036%20months,10.65,162.87,10,RENT,24000,VERIFIED%20-%20income,AZ,27.65,0,13648,83.7,0"`

Please note: Public IPv4 address of the instance where the H2O REST Server is running is needed to enable Snowflake to send requests through AWS API Gateway.
Additionally, verify that the port 8080 (default) is open on the firewall or change the port with the `-DServer.port` option in the `goServer.sh` script.

AWS & Snowflake Infrastructure Setup
------------------------------------

Using the Snowflake External Functions require setup and configuration between Snowflake and AWS.

The Snowflake documentation can be used as a guide for the detailed steps:
https://docs.snowflake.com/en/sql-reference/external-functions-creating-aws.html

A setup script is available in the Infrastructure-Automation directory, which automates the complete infrastructure setup between Snowflake and AWS.

To start the setup program, execute the script setup.sh from the Infrastructure-Automation directory.

Requirements: Python 3.6 and pip
