Skip to content

Instantly share code, notes, and snippets.

@mtanco
mtanco / dai_unsupervised.ipynb
Created July 13, 2022 04:09
Running all unsupervised model types on a dataset with Driverless AI.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mtanco
mtanco / wave_home_header_image.py
Created June 3, 2022 15:50
The app shows how you can route to a different hash page, and then go to the home of the app by clicking an image in the header card.
from h2o_wave import main, app, Q, ui, on, handle_on
@app('/')
async def serve(q: Q):
print(q.args)
# First time a browser comes to the app
if not q.client.initialized:
await init(q)
@mtanco
mtanco / mlops_deployment_app.py
Created March 7, 2022 23:52
Set a nice name and an MLOps deployment, get a nice app
import json
import requests
from h2o_wave import main, app, Q, ui, expando_to_dict
ENDPOINT = "https://model.DOMAIN.h2o.ai/MODELID/model"
APP_TITLE = "My Use Case"
@mtanco
mtanco / stream_text.py
Last active July 12, 2022 22:53
Display fake-streamed text data using H2O Wave. Pause and resume the real-time updates.
"""
Demo of Updating App Data in one card of an app
"""
from random import randint
from h2o_wave import Q, app, handle_on, main, on, ui
@app("/")
async def serve(q: Q):
@mtanco
mtanco / clickable_wave_table.py
Created December 3, 2021 17:48
How to make a table from a pandas data frame and do something when one of the rows is clicked in H2O Wave.
from h2o_wave import main, app, Q, ui
import pandas as pd
import numpy as np
@app('/')
async def serve(q: Q):
print(q.args)
if not q.client.initialized:
@mtanco
mtanco / mlops_predictions.py
Created September 24, 2021 17:10
An example of how to get predictions from a REST endpoint.
import json
import numpy as np
import pandas as pd
import requests
"""
Suggestions on how to use this in an H2O Wave app:
1. Have a page with a textbox asking users for a URL of a REST endpoint
2. Allow users to upload a CSV with new data
@mtanco
mtanco / stock_ticker_wave.py
Created September 8, 2021 23:34
Wave for Python Stock Ticker Sample App
from h2o_wave import main, app, ui, Q, on, handle_on, data
from pandas_datareader import data as web
import pandas as pd
from datetime import datetime as dt
@app("/")
async def serve(q: Q):
stock = q.args["my-dropdown"] or "COKE"
@mtanco
mtanco / ScheduledInteractiveApp.py
Last active May 11, 2021 19:46
Use the AsyncIOScheduler to run a scheduled job for updating a dashboard while maintaining the ability to use all features of an interactive app
import random
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from h2o_wave import main, app, Q, ui, handle_on, on, data
SCHEDULER = AsyncIOScheduler()
@app('/')
@mtanco
mtanco / wave_background_tests.py
Created May 5, 2021 16:41
This Gist extends the https://wave.h2o.ai/docs/examples/background/ example and shows that apps are still interactive while running background tasks.
import time
import random
from h2o_wave import main, app, Q, ui
def sleeper_agent(secs) -> str:
time.sleep(secs) # Blocks!
return f'Done waiting for {secs} seconds!'
@mtanco
mtanco / permanate_cards.py
Last active April 27, 2021 18:21
The example application creates a new card from user text, all past cards stay on the page, and cards can be cleared with an additional button
from datetime import datetime
from h2o_wave import main, app, Q, ui, on, handle_on
from loguru import logger
def on_startup():
logger.info('http://localhost:10101')