### Run Button Example Source: https://github.com/h2oai/wave/blob/main/website/docs/contributing.md Executes the button example to verify the development setup. Assumes you are in the 'py' directory and have a virtual environment set up. ```bash cd py && ./venv/bin/wave run examples.button ``` -------------------------------- ### Install H2O Wave SDK and Run an App Source: https://context7.com/h2oai/wave/llms.txt Commands to install the H2O Wave Python SDK, start a development server, and fetch examples. ```bash pip install h2o-wave wave run app wave run --no-reload app wave fetch pip install h2o_wave_university wave learn wave share ``` -------------------------------- ### Basic Image Annotator Setup Source: https://github.com/h2oai/wave/blob/main/website/widgets/ai/image_annotator.md Demonstrates the basic setup of the image annotator with predefined tags and initial annotations. Use this to start annotating images with bounding boxes and polygons. ```python image = 'https://images.pexels.com/photos/2696064/pexels-photo-2696064.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1' q.page['example'] = ui.form_card(box='1 1 9 10', items=[ ui.image_annotator( name='annotator', title='Drag to annotate', image=image, image_height='700px', tags=[ ui.image_annotator_tag(name='p', label='Person', color='$cyan'), ui.image_annotator_tag(name='f', label='Food', color='$blue'), ], items=[ ui.image_annotator_item(shape=ui.image_annotator_rect(x1=649, y1=393, x2=383, y2=25), tag='p'), ui.image_annotator_item(tag='p', shape=ui.image_annotator_polygon([ ui.image_annotator_point(x=828.2142857142857, y=135), ui.image_annotator_point(x=731.7857142857142, y=212.14285714285714), ui.image_annotator_point(x=890.3571428571429, y=354.6428571428571), ui.image_annotator_point(x=950.3571428571429, y=247.5) ])), ], ), ui.button(name='submit', label='Submit', primary=True) ]) ``` -------------------------------- ### Run Example App Source: https://github.com/h2oai/wave/blob/main/website/docs/installation.mdx Use this command to run a specific example application, such as 'todo.py'. Access the running example via the provided URL. ```shell wave run examples.todo ``` -------------------------------- ### Complete Wide Bar Stat Card Setup in R Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-04-28-R-release.md A comprehensive example demonstrating the initialization of a Wave page, dynamic data generation, adding a wide bar stat card, and saving the page. ```r library(h2owave) page <- Site("/demo") crypto_price <- runif(1,1,500) crypto_price_change <- runif(1,0,1) page$add_card("wide_bar",ui_wide_bar_stat_card(box="1 1 2 1" ,title="ETH" ,value='=${{intl price minimum_fraction_digits=2 maximum_fraction_digits=2}}' ,aux_value='={{intl change style="percent" minimum_fraction_digits=2 maximum_fraction_digits=2}}' ,plot_color='$red' ,data=list(price=crypto_price,change=crypto_price_change) ,progress = crypto_price_change )) page$save() ``` -------------------------------- ### R Wave Dashboard Example Source: https://github.com/h2oai/wave/blob/main/website/blog/2022-05-31-release.md Illustrates how to create a simple R Wave dashboard with a Markdown card. This example shows basic page setup and adding content. ```r library(h2owave) page <- Site("/demo") page$drop() page$add_card("hello", ui_markdown_card( box="1 1 2 2", title="Hello World!", content='And now for something completely different!' )) page$save() ``` -------------------------------- ### Fetch Wave Examples and Demos Source: https://github.com/h2oai/wave/blob/main/website/docs/installation.mdx Use the `wave fetch` command to download example applications, demos, and the interactive tour to your local machine. ```shell (venv) $ wave fetch ``` -------------------------------- ### Fetch Interactive Wave Examples Source: https://github.com/h2oai/wave/blob/main/py/h2o_wave/project_templates/README.md Run this command to download interactive Python examples that demonstrate H2O Wave functionality. These examples can be edited directly in the browser. ```shell wave fetch ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/h2oai/wave/blob/main/website/README.md Clone the repository and install project dependencies for the Wave website and showcase tools. ```console git clone https://github.com/h2oai/wave.git cd wave/py make setup make docs cd ../tools/showcase make setup make generate cd ../../website npm ci ``` -------------------------------- ### Start UI Development Server Source: https://github.com/h2oai/wave/blob/main/website/docs/contributing.md Starts the UI development server for front-end development. Changes in the './ui' directory will be reflected in real time. ```bash make run-ui ``` -------------------------------- ### Install All Development Dependencies Source: https://github.com/h2oai/wave/blob/main/website/docs/contributing.md Run this command after cloning the repository to set up all necessary development dependencies. ```bash make all ``` -------------------------------- ### Start Local Development Server Source: https://github.com/h2oai/wave/blob/main/website/README.md Starts a local development server for the website. Changes are reflected live without a server restart. ```console npm start ``` -------------------------------- ### Install and Run H2O Wave University Source: https://github.com/h2oai/wave/blob/main/university/README.md Follow these steps to set up and launch the Wave University interactive tutorial. Ensure you are using a virtual environment for installation. ```sh python -m venv venv venv/bin/activate pip install h2o-wave-university wave-university ``` -------------------------------- ### Fetch Wave Examples Locally Source: https://github.com/h2oai/wave/blob/main/website/blog/2022-01-30-release.md Downloads Wave app examples, demos, and the interactive tour to your local machine. This command fetches necessary files and extracts them to designated directories. ```shell (venv) $ wave fetch Fetching examples and related files. Please wait... Downloading https://github.com/h2oai/wave/releases/download/v0.19.0/wave-0.19.0-linux-amd64.tar.gz Extracting... All additional files downloaded and extracted successfully! Examples and tour............. /home/wave/examples Demos and layout samples...... /home/wave/demo Automated test harness........ /home/wave/test Wave daemon for deployments... /home/wave ``` -------------------------------- ### Install Cypress Source: https://github.com/h2oai/wave/blob/main/website/docs/browser-testing.md Install Cypress using npm in your Wave installation's test directory. ```bash cd $HOME/wave/test npm install ``` -------------------------------- ### Install H2O Lightwave with Web Support Source: https://github.com/h2oai/wave/blob/main/website/docs/lightwave.md Install the h2o-lightwave package with the 'web' extra to include necessary web dependencies. ```bash pip install "h2o-lightwave[web]" ``` -------------------------------- ### Install H2O Wave in a Windows Virtual Environment Source: https://github.com/h2oai/wave/blob/main/website/docs/installation.mdx Set up a Python virtual environment on Windows and install H2O Wave within it. ```shell python -m venv venv .\venv\Scripts\activate pip install h2o-wave ``` -------------------------------- ### Install H2O Wave University Source: https://github.com/h2oai/wave/blob/main/website/docs/getting-started.md Install the H2O Wave University package to access interactive learning. This package can be installed independently. ```shell pip install h2o_wave_university ``` -------------------------------- ### Start Python REPL Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-hello.mdx Starts an interactive Python REPL session within the Wave application's virtual environment. ```shell cd $HOME/wave-apps ./venv/bin/python ``` -------------------------------- ### Fetch Wave Examples with Platform and Architecture Options Source: https://github.com/h2oai/wave/blob/main/website/docs/cli.md Specify the operating system platform and processor architecture when using 'wave fetch' to download specific versions of examples and executables. ```sh wave fetch --platform [linux|windows|darwin] --arch [amd64|arm64] ``` -------------------------------- ### Install h2o-wave Package Source: https://github.com/h2oai/wave/blob/main/website/docs/development.md Install the h2o-wave package into a Python virtual environment. This is a prerequisite for developing Wave applications. ```shell mkdir $HOME/wave-apps cd $HOME/wave-apps python3 -m venv venv ./venv/bin/pip install h2o-wave ``` -------------------------------- ### Start Wave Server with Custom Access Keys Source: https://github.com/h2oai/wave/blob/main/website/docs/security.md Use this command to start the Wave server with specific access key ID and secret for development. ```shell ./waved -access-key-id -access-key-secret ``` -------------------------------- ### Install Requirements for Wave Tour Source: https://github.com/h2oai/wave/blob/main/website/docs/installation.mdx Install the necessary Python packages to run the Wave tour application. ```shell cd wave pip install -r examples/requirements.txt ``` -------------------------------- ### Install R Prerequisites Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-04-28-R-release.md Installs necessary R packages for H2O Wave development. Ensure these are installed before proceeding with the Wave package. ```r install.packages(c("R6","devtools","jsonlite","stringr","httr")) ``` -------------------------------- ### Start Wave Server with Custom Keychain Source: https://github.com/h2oai/wave/blob/main/website/docs/security.md Launch the Wave server and configure it to use a specific keychain file for authentication. ```shell ./waved -access-keychain /path/to/file.extension ``` -------------------------------- ### Launch Wave Server Source: https://github.com/h2oai/wave/blob/main/website/docs/contributing.md Command to start the Wave server for local development and testing. ```bash make run ``` -------------------------------- ### Install psutil Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-monitor.md Install the psutil package, which is used to read system statistics. ```shell pip install psutil ``` -------------------------------- ### Start and Query WaveDB (SQLite over HTTP) Source: https://context7.com/h2oai/wave/llms.txt This bash command starts the WaveDB service, which acts as an HTTP wrapper for SQLite. It requires specifying an access key ID, secret, and the directory for database files. Subsequent queries are made using `curl` with basic authentication. ```bash # Start WaveDB (defaults to port 10100) ./wavedb -access-key-id mykey -access-key-secret mysecret -dir /path/to/dbs # Query via curl curl -s -u mykey:mysecret \ -d '{"e":{"d":"mydb","s":[{"q":"SELECT name, age FROM users LIMIT 3"}]}}' \ http://localhost:10100 ``` -------------------------------- ### Basic Table Example Source: https://github.com/h2oai/wave/blob/main/website/widgets/form/table.md Demonstrates how to create a basic table with columns and rows. The 'name' attribute is used to reference the table in query arguments. ```python q.page['example'] = ui.form_card(box='1 1 3 3', items=[ ui.table( name='table', columns=[ ui.table_column(name='name', label='Name'), ui.table_column(name='surname', label='Surname'), ], rows=[ ui.table_row(name='row1', cells=['John', 'Doe']), ui.table_row(name='row2', cells=['Alice', 'Smith']), ui.table_row(name='row3', cells=['Bob', 'Adams']), ] ) ]) ``` -------------------------------- ### Install H2O Wave ML Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-03-08-ml-release.md Install H2O Wave ML along with H2O Wave using pip. ```APIDOC ## Install H2O Wave ML Install H2O Wave ML along with H2O Wave using pip: ```shell (venv) $ pip install h2o-wave[ml] ``` To use the package, simply import `h2o_wave_ml`: ```py import h2o_wave_ml ``` ``` -------------------------------- ### Run System Monitor Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-monitor.md Execute the Python script to start the system monitoring tool. ```shell python system_monitor.py ``` -------------------------------- ### Start Wave Server (Windows) Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-hello.mdx Starts the Wave server on Windows. Keep this terminal open while running Wave apps or scripts. ```shell waved.exe ``` -------------------------------- ### Start Wave Server (Unix/MacOS) Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-hello.mdx Starts the Wave server on Unix-like systems. Keep this terminal open while running Wave apps or scripts. ```shell ./waved ``` -------------------------------- ### Install H2O Lightwave Source: https://github.com/h2oai/wave/blob/main/py/h2o_lightwave/README.md Installs H2O Lightwave with web support. Additional libraries like 'websockets' may be required for frameworks such as Starlette and FastAPI. ```bash pip install "h2o-lightwave[web]" ``` ```bash pip install websockets ``` -------------------------------- ### Basic ChoiceGroup Example Source: https://github.com/h2oai/wave/blob/main/website/widgets/form/choice_group.md Demonstrates the basic usage of the ui.choice_group component with three options. ```python q.page['example'] = ui.form_card(box='1 1 2 2', items=[ ui.choice_group(name='choice_group', label='Choice group', choices=[ ui.choice('A', 'Option A'), ui.choice('B', 'Option B'), ui.choice('C', 'Option C'), ]) ]) ``` -------------------------------- ### Launch WaveDB Source: https://github.com/h2oai/wave/blob/main/website/docs/wavedb.md Launch the WaveDB executable. By default, it listens on http://localhost:10100/. The output shows the server starting and the port it's listening on. ```sh ./wavedb ``` -------------------------------- ### Run Python Script Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-beer.md Execute the Python script to start the Wave application and generate the beer wall verses. ```shell python beer_wall.py ``` -------------------------------- ### Initialize and Display To-Do List Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-todo.md Sets up the main application route and displays the initial to-do list. Creates sample items if none exist for the user. ```python @app('/todo') async def serve(q: Q): show_todos(q) await q.page.save() def show_todos(q: Q): # Get items for this user. todos: List[TodoItem] = q.user.todos # Create a sample list if we don't have any. if todos is None: q.user.todos = todos = [TodoItem('Do this'), TodoItem('Do that'), TodoItem('Do something else')] # Create done/not-done checkboxes. done = [ui.checkbox(name=todo.id, label=todo.text, value=True, trigger=True) for todo in todos if todo.done] not_done = [ui.checkbox(name=todo.id, label=todo.text, trigger=True) for todo in todos if not todo.done] # Display list q.page['form'] = ui.form_card(box='1 1 3 10', items=[ ui.text_l('To Do'), *not_done, *([ui.separator('Done')] if len(done) else []), *done, ]) ``` -------------------------------- ### Create a Basic Link Source: https://github.com/h2oai/wave/blob/main/website/widgets/form/link.md Use ui.link to create a basic hyperlink. Internal hyperlinks start with '/', while others are treated as external. ```python q.page['example'] = ui.form_card(box='1 1 2 2', items=[ ui.link(label='Go to h2o.ai', path='https://www.h2o.ai/') ]) ``` -------------------------------- ### Hello World App Source: https://github.com/h2oai/wave/blob/main/py/h2o_wave/README.rst A basic H2O Wave application that displays a 'Hello world!' message. This serves as a starting point for Wave applications. ```python from h2o_wave import main, app, Q, ui @app('/') async def serve(q: Q): q.page['hello'] = ui.markdown_card( box='1 1 3 3', title='Hello world!', content='Welcome to Wave!' ) await q.page.save() ``` -------------------------------- ### FastAPI Integration with H2O Lightwave Source: https://github.com/h2oai/wave/blob/main/py/h2o_lightwave/README.md Integrates H2O Lightwave into a FastAPI application. This example demonstrates setting up a Wave callback function, handling UI rendering, and managing user interactions like button clicks. Ensure websockets are installed for Starlette & FastAPI. ```python from fastapi import FastAPI, WebSocket, WebSocketDisconnect from fastapi.staticfiles import StaticFiles from h2o_lightwave import Q, ui, wave_serve from h2o_lightwave_web import web_directory # Lightwave callback function. async def serve(q: Q): # Paint our UI on the first page visit. if not q.client.initialized: # Create a local state. q.client.count = 0 # Add a "card" with a text and a button q.page['hello'] = ui.form_card(box='1 1 2 2', items=[ ui.text_xl('Hello world'), ui.button(name='counter', label=f'Current count: {q.client.count}'), ]) q.client.initialized = True # Handle counter button click. if q.args.counter: # Increment the counter. q.client.count += 1 # Update the counter button. q.page['hello'].items[1].button.label = f'Current count: {q.client.count}' # Send the UI changes to the browser. await q.page.save() # Run: uvicorn hello_fastapi:app. # FastAPI boilerplate. app = FastAPI() # FastAPI: WebSocket must be registered before index.html handler. @app.websocket("/_s/") async def ws(ws: WebSocket): try: await ws.accept() await wave_serve(serve, ws.send_text, ws.receive_text) await ws.close() except WebSocketDisconnect: print('Client disconnected') app.mount("/", StaticFiles(directory=web_directory, html=True), name="/") ``` -------------------------------- ### Full Example: Dynamic Card Update Loop Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-04-28-R-release.md This comprehensive R script initializes a Wave page, adds a wide bar stat card with initial data, and then enters a loop to continuously update the card's price, change, and progress parameters every 3 seconds. Ensure the h2owave library is installed and loaded. ```R library(h2owave) page <- Site("/demo") crypto_price <- runif(1,1,500) crypto_price_change <- runif(1,0,1) page$add_card("wide_bar",ui_wide_bar_stat_card(box="1 1 2 1" ,title="ETH" ,value='=${{intl price minimum_fraction_digits=2 maximum_fraction_digits=2}}' ,aux_value='={{intl change style="percent" minimum_fraction_digits=2 maximum_fraction_digits=2}}' ,plot_color='$red' ,data=list(price=crypto_price,change=crypto_price_change) ,progress = crypto_price_change )) page$save() while(TRUE){ Sys.sleep(3) crypto_price <- runif(1,1,500) crypto_price_change <- runif(1,0,1) page$set("wide_bar","data","price",crypto_price) page$set("wide_bar","data","change",crypto_price_change) page$set("wide_bar","progress",crypto_price_change) page$save() } ``` -------------------------------- ### Install h2owave R Package from Command Line Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-04-28-R-release.md Installs the h2owave R package using the R CMD INSTALL command. This is an alternative to installing from within an R session. ```bash R CMD INSTALL h2owave_0.0.14.tar.gz ``` -------------------------------- ### Install H2O Wave with Pip Source: https://github.com/h2oai/wave/blob/main/website/docs/installation.mdx Use pip to install the H2O Wave Python package. This is the most common installation method. ```shell pip install h2o-wave ``` -------------------------------- ### Initialize a Wave Project Source: https://github.com/h2oai/wave/blob/main/website/docs/cli.md Use the 'wave init' command to set up the basic structure for a new Wave project, often by selecting a starter template. ```sh wave init ``` -------------------------------- ### Create Basic Menu Source: https://github.com/h2oai/wave/blob/main/website/widgets/form/menu.md Demonstrates how to create a basic contextual menu with a list of commands. This is useful for providing a set of actions to the user. ```python q.page['form'] = ui.form_card( box='1 1 2 2', items=[ ui.menu(items=[ ui.command(name='profile', label='Profile', icon='Contact'), ui.command(name='preferences', label='Preferences', icon='Settings'), ui.command(name='logout', label='Logout', icon='SignOut'), ]) ] ) ``` -------------------------------- ### Install Nightly Build Source: https://github.com/h2oai/wave/blob/main/website/docs/installation.mdx Use this command to install a nightly build of H2O Wave from a downloaded .whl file. This is an alternative to the standard pip install command. ```shell pip install .whl ``` -------------------------------- ### Run Demo Application Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-01-17-release.md Execute the demo application to explore Wave's capabilities. Ensure you are in the correct virtual environment. ```shell (venv) $ wave run demo.app ``` -------------------------------- ### Install H2O Wave Source: https://github.com/h2oai/wave/blob/main/py/h2o_wave/README.rst Install or update the H2O Wave package using pip. ```text pip install -U h2o-wave ``` -------------------------------- ### Define App and Initial Handler Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-todo.md Sets up the basic Wave application structure with an @app decorator and an initial serve function. It calls a placeholder show_todos function and saves the page. ```Python from h2o_wave import Q, main, app, ui @app('/todo') async def serve(q: Q): show_todos(q) await q.page.save() def show_todos(q: Q): pass ``` -------------------------------- ### Manage User's Todo List Source: https://github.com/h2oai/wave/blob/main/website/docs/tutorial-todo.md Initializes or retrieves the user's to-do list from q.user. If no list exists, it creates a new one with sample items. ```Python from typing import List from h2o_wave import Q, main, app, ui _id = 0 # A simple class that represents a to-do item. class TodoItem: def __init__(self, text): global _id _id += 1 self.id = f'todo_{_id}' self.text = text self.done = False @app('/todo') async def serve(q: Q): show_todos(q) await q.page.save() def show_todos(q: Q): # Get items for this user. todos: List[TodoItem] = q.user.todos # Create a sample list if we don't have any. if todos is None: q.user.todos = todos = [TodoItem('Do this'), TodoItem('Do that'), TodoItem('Do something else')] ``` -------------------------------- ### Provide File Downloads to Browser Source: https://github.com/h2oai/wave/blob/main/website/docs/files.md Use `q.site.upload()` to send files from your app to the Wave server. The returned paths can be used in `ui.link()` to create download links for users. Multiple files can be uploaded at once. ```python from h2o_wave import Q, main, app, ui @app('/downloads') async def serve(q: Q): download_path, = await q.site.upload(['results.csv']) q.page['download'] = ui.form_card(box='1 1 2 2', items = [ ui.link(label='Download Results', path=download_path, download=True), ]) await q.page.save() ``` -------------------------------- ### Run Wave App Source: https://github.com/h2oai/wave/blob/main/website/docs/configuration.md Starts the Wave application server. Use --no-reload for development. The output shows the server address and the web directory location. ```sh wave run app --no-reload 2023/09/12 14:24:35 # 2023/09/12 14:24:35 # ┌────────────────┐ H2O Wave 2023/09/12 14:24:35 # │ ┐┌┐┐┌─┐┌ ┌┌─┐ │ 0.26.2 20230803101411 2023/09/12 14:24:35 # │ └┘└┘└─└└─┘└── │ © 2021 H2O.ai, Inc. 2023/09/12 14:24:35 # └────────────────┘ 2023/09/12 14:24:35 # ┌──────────────────────────────────────┐ 2023/09/12 14:24:35 # │ Running at http://localhost:10101/ │ 2023/09/12 14:24:35 # └──────────────────────────────────────┘ 2023/09/12 14:24:35 # {"address":":10101","base-url":"/","t":"listen","web-dir":"/path/to/venv/www"} INFO: Started server process [10429] INFO: Waiting for application startup. 2023/09/12 14:24:36 # {"host":"http://127.0.0.1:8000","route":"/","t":"app_add"} INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) ``` -------------------------------- ### Python Turtle Graphics Example Source: https://github.com/h2oai/wave/blob/main/website/docs/graphics.md This is a direct translation of a Python turtle graphics example. It uses basic turtle commands to draw a shape with fill. ```python from turtle import * color('red', 'yellow') begin_fill() while True: forward(200) left(170) if abs(pos()) < 1: break end_fill() done() ``` -------------------------------- ### R Wave App Example Source: https://github.com/h2oai/wave/blob/main/website/blog/2022-05-31-release.md Demonstrates a basic R Wave app that includes a counter button. It shows how to serve an app and update UI elements based on user interaction. ```r library(h2owave) serve <- function(qo) { qo$client$test <- ifelse(is.null(qo$client$test),0, qo$client$test) ifelse(qo$args$increment == TRUE,qo$client$test <- qo$client$test + 1,qo$client$test <- 0) if(length(qo$args) == 0 || qo$args$increment == FALSE){ qo$page$add_card("button_entry",ui_form_card( box='1 1 12 10' ,items = list( ui_button( name='increment' ,label=paste0('Count= ',qo$client$test) ,primary = TRUE ) ) )) } else { qo$page$set("button_entry","items","0","button","label",paste0("Count=",qo$client$test)) } qo$page$save() } app("/") ``` -------------------------------- ### Install H2O Wave in a Conda Virtual Environment Source: https://github.com/h2oai/wave/blob/main/website/docs/installation.mdx Create and activate a Conda environment, then install H2O Wave. Conda packaging does not include the Wave server. ```shell conda create -n venv conda activate venv conda config --append channels conda-forge conda install -c h2oai h2o-wave ``` -------------------------------- ### Create a Basic Markup Card Source: https://github.com/h2oai/wave/blob/main/website/widgets/content/markup.md Use `ui.markup_card` to display raw HTML content. Prefer native Wave components when possible. ```python menu = '''
  1. Spam
  2. Ham
  3. Eggs
''' q.page['example'] = ui.markup_card(box='1 1 2 2', title='Menu', content=menu) ``` -------------------------------- ### Install H2O Wave with Conda Source: https://github.com/h2oai/wave/blob/main/website/docs/installation.mdx Install H2O Wave using Conda. Note that Conda packaging does not include the Wave server, which must be run separately. ```shell conda config --append channels conda-forge conda install -c h2oai h2o-wave ``` -------------------------------- ### Create a Basic Visualization Source: https://github.com/h2oai/wave/blob/main/website/widgets/form/visualization.md Demonstrates the fundamental usage of the `ui.visualization` component to display a simple interval plot. Ensure `h2o_wave` is imported. ```python from h2o_wave import data q.page['example'] = ui.form_card(box='1 1 4 4', items=[ ui.visualization( plot=ui.plot([ui.mark(type='interval', x='=product', y='=price', y_min=0)]), data=data(fields='product price', rows=[ ('category1', 7), ('category2', 8), ('category3', 9), ]), ), ]) ``` -------------------------------- ### WaveDB Command-Line Help Source: https://github.com/h2oai/wave/blob/main/website/docs/wavedb.md Output from the `./wavedb -help` command, detailing available command-line options for configuring and running the WaveDB server. ```bash $ ./wavedb -help Usage of ./wavedb: -access-key-id string default API access key ID (default "access_key_id") -access-key-secret string default API access key secret (default "access_key_secret") -access-keychain string path to file containing API access keys (default ".wave-keychain") -benchmark int run benchmarks for the given number of iterations -dir string path to directory containing database (.db) files (default ".") -listen string listen on this address (default ":10100") -tls-cert-file string path to certificate file (TLS only) -tls-key-file string path to private key file (TLS only) -verbose enable verbose logging -version print version and exit ``` -------------------------------- ### Wave App Routing with 'run_on' (Recommended) Source: https://github.com/h2oai/wave/blob/main/website/blog/2023-10-09-release.md Example of Wave app routing using the 'run_on' function, which addresses the limitations of 'handle_on' by reliably invoking handlers based on user actions. ```python from h2o_wave import app, main, Q, ui, on, run_on @app("/") async def serve(q: Q) -> None: if not q.client.initialized: q.page['example'] = ui.form_card(box='1 1 2 2', items=[ ui.textbox(name='textbox', label='Textbox', value='Hello!'), ui.button(name='button', label='Click me') ]) q.client.initialized = True await run_on(q) await q.page.save() @on() async def textbox(q: Q): q.page['example'] = ui.form_card(box='1 1 2 2', items=[ ui.text('Textbox triggered.'), ]) @on() async def button(q: Q): q.page['example'] = ui.form_card(box='1 1 2 2', items=[ ui.text('Button triggered.'), ]) ``` -------------------------------- ### Install h2owave R Package from R Environment Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-04-28-R-release.md Installs the h2owave R package directly from an R interactive environment. This method requires specifying the repository as NULL and type as 'source'. ```r install.packages("h2owave_0.0.14.tar.gz",repos=NULL,type="source") ``` -------------------------------- ### Install H2O Wave ML Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-03-08-ml-release.md Install the H2O Wave ML package along with H2O Wave using pip. This command ensures both core Wave functionality and the ML extension are available. ```shell $ pip install h2o-wave[ml] ``` -------------------------------- ### Configure Wave Server with CLI Flags Source: https://context7.com/h2oai/wave/llms.txt Start the Wave server manually with custom settings for listening address, access keys, data directory, TLS certificates, public/private directories, session expiry, and OIDC integration. ```bash # Start Wave server manually with custom settings ./waved \ -listen :10101 \ -access-key-id myid \ -access-key-secret mysecret \ -data-dir /var/wave/data \ -tls-cert-file /etc/ssl/cert.pem \ -tls-key-file /etc/ssl/key.pem \ -public-dir /static/@/var/wave/static \ -private-dir /reports/@/var/wave/reports \ -session-expiry 24h \ -oidc-provider-url https://keycloak.example.com/realms/myrealm \ -oidc-client-id wave-app \ -oidc-client-secret supersecret \ -oidc-redirect-url https://myapp.example.com/_auth/callback ``` -------------------------------- ### Start Cypress Test Runner Source: https://github.com/h2oai/wave/blob/main/website/docs/browser-testing.md Open the Cypress test runner from your terminal. ```bash cd $HOME/wave/test ./node_modules/.bin/cypress open ``` -------------------------------- ### Serve Built Website Locally Source: https://github.com/h2oai/wave/blob/main/website/README.md Serves the locally built static website content. This command should be used after running 'npm run build'. ```console npm run serve ``` -------------------------------- ### Serve Images from App to Wave Server Source: https://github.com/h2oai/wave/blob/main/website/docs/files.md Upload images from your app to the Wave server using `q.site.upload()`. The returned path can then be used in `ui.image()` or `ui.image_card()` to display the image. ```python image, = await q.site.upload(['path/to/my/image.png']) q.page['example'] = ui.form_card(box='1 1 4 4', items=[ ui.image(title='Image title', image=image, type='png'), ]) ``` -------------------------------- ### Basic Dropdown Example Source: https://github.com/h2oai/wave/blob/main/website/widgets/form/dropdown.md Demonstrates how to create a simple dropdown with a label and a list of choices. The 'name' attribute is used to reference the component's value in query arguments. ```Python q.page['example'] = ui.form_card(box='1 1 2 2', items=[ ui.dropdown(name='dropdown', label='Dropdown', choices=[ ui.choice(name='choice1', label='Choice 1'), ui.choice(name='choice2', label='Choice 2'), ui.choice(name='choice3', label='Choice 3'), ]) ]) ``` -------------------------------- ### Run Wave App with ASGI Server (uvicorn) Source: https://github.com/h2oai/wave/blob/main/website/blog/2020-10-28-release.md Command to run a Wave app using an ASGI server like uvicorn, appending ':main' to specify the app entry point. ```shell (venv) $ uvicorn foo:main ``` -------------------------------- ### Build Custom Wave Studio App Source: https://github.com/h2oai/wave/blob/main/studio/README.md Navigate to the studio directory, set up the environment, and build a custom version of the Wave Studio app. Specify the desired version using the VERSION argument. ```sh cd studio make setup VERSION=1.2.3 make build ``` -------------------------------- ### Blocking Function Example Source: https://github.com/h2oai/wave/blob/main/website/blog/2020-10-28-release.md Defines a Python function that simulates a blocking operation using `time.sleep()`. ```python import time def blocking_function(seconds) -> str: time.sleep(seconds) # Blocks! return f'Done!' ``` -------------------------------- ### Configure Wave Daemon with Keycloak Source: https://github.com/h2oai/wave/blob/main/website/docs/development.md Start the Wave daemon with OpenID Connect (OIDC) arguments to integrate with Keycloak. Ensure you use the correct client ID, secret, redirect URL, and provider URL. ```bash ./waved \ -oidc-client-id wave \ -oidc-client-secret xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \ -oidc-redirect-url http://localhost:10101/_auth/callback \ -oidc-provider-url http://localhost:8080/realms/master \ -oidc-end-session-url http://localhost:8080/realms/master/protocol/openid-connect/logout ``` -------------------------------- ### Import H2O Wave ML Source: https://github.com/h2oai/wave/blob/main/website/blog/2021-03-08-ml-release.md Import the h2o_wave_ml package to start using its functionalities in your Python script. ```python import h2o_wave_ml ```