Skip to content

Instantly share code, notes, and snippets.

@ahmedengu
Last active December 18, 2019 18:16
Show Gist options
  • Save ahmedengu/7780e56e7ff42bbab53147e685c07f74 to your computer and use it in GitHub Desktop.
Save ahmedengu/7780e56e7ff42bbab53147e685c07f74 to your computer and use it in GitHub Desktop.
Installing and running H2O flow on google colab using and access it ngrok, Don't forget setting ngrok auth key
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "H2O_Flow",
"version": "0.3.2",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/ahmedengu/7780e56e7ff42bbab53147e685c07f74/h2o_flow.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"metadata": {
"id": "KFs57E-6hM8l",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"# Download h2o\n",
"!wget -c http://h2o-release.s3.amazonaws.com/h2o/rel-xia/2/h2o-3.22.0.2.zip\n",
"!unzip -n h2o-3.22.0.2.zip \n",
"\n",
"# Install ngrok\n",
"! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip\n",
"! unzip -qq -n ngrok-stable-linux-amd64.zip"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "8MnDqhLPDsP1",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"NGROK_AUTH = \"NGROK_AUTH\"\n",
"\n",
"from time import sleep\n",
"from IPython.display import clear_output\n",
"import requests\n",
"import json\n",
"\n",
"# keep everything running\n",
"i=0\n",
"while True:\n",
" try:\n",
" # start h2o\n",
" if len(get_ipython().getoutput('ps -ef | grep h2o')) <= 2:\n",
" get_ipython().system_raw('java -jar h2o-3.22.0.2/h2o.jar &')\n",
" sleep(5)\n",
"\n",
" ngrok_link = json.loads(requests.get('http://localhost:4040/api/tunnels').text)['tunnels'][0]['public_url']\n",
" print(ngrok_link)\n",
" sleep(30)\n",
" requests.get(ngrok_link)\n",
" except (KeyboardInterrupt, SystemExit):\n",
" raise\n",
" except:\n",
" # create ngrok port\n",
" get_ipython().system_raw('./ngrok authtoken $NGROK_AUTH && ./ngrok http 54321 &')\n",
" i+=1\n",
" if i >=5:\n",
" clear_output(wait=True)\n",
" i=0\n"
],
"execution_count": 0,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment