Skip to main content

Importing a Wave App

This tutorial guides you through importing a Wave app to the App Store, so you can iteratively develop and prototype the app and then publish it to users.

Before you begin

Before you begin, you must have the following artifacts:

  • Access to the H2O AI Cloud App Store
  • App upload permissions
  • The Wave App source code of the app that you wish to upload

App configurations

First, ensure that your app source code is bundled and ready for import. For more information about app bundle structure, see Developer Guide.

There are a few more files that are required before you go ahead and import to the App Store.

  1. requirements.txt file - Create a file called requirements.txt to indicate which packages and versions to install in the Python virtual environment when running the app on the App Store.

    sample requirements.txt file
    altair==4.1.0
    h2o-wave==0.20.0
    note

    For production use cases, always pin your libraries and their transitive dependencies in the requirements.text with a specific version to ensure that your app does not break or get unexpected behavior when a new version of a library is available on PyPi. For more information, see Requirements File Format in the Pip documentation.

  2. app.toml file - Create a new file called app.toml. This is a configuration file that tells the App Store how to present the app to end users and how to run it. It contains details such as the location path to the entry point of the source code, app title, app secrets, and indicates any special configuration for running the app such as whether or not users need to log in to use the app, should there be GPUs, etc.

    sample app.toml file
    [App]
    Name = "ai.h2o.wave.my-first-app"
    Version = "0.0.1"
    Title = "Hello, World!"
    Description = "Show a card to the user explaining this is my first app."

    [Runtime]
    Module = "app"
    notes
    • To see the full list of configuration options for this file, see Developer Guide - app.toml.

    • Module is the name name of the python module that is the entrypoint of the app (relative to the app.toml file). If you have all your source code in a folder called src and your main app file is called app.py, the value for Module would be src.app. For more information about Python Modules, see the Python Documentation. :::

  3. app.py file - This is the main source code file for your Python app.

    sample app.py file
    from h2o_wave import Q, app, main, ui  # noqa: F401

    @app("/")
    async def serve(q: Q):
    q.page["lorem"] = ui.markdown_card(
    box="1 1 2 2",
    title="Lorem Ipsum",
    content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin id blandit nunc.",
    )
    await q.page.save()

Importing and publishing an app

You can import your app to the App Store using one of the following methods. The easiest and fastest way to deploy, run, and manage your app is using the H2O CLI, however you can also use the GUI if you prefer.

Using H2O CLI

  1. Set up and configure H2O CLI.

  2. Navigate to your app's source directory on the command line.

  3. Run the following command to immediately import and run your app on the App Store.

    h2o bundle deploy --generate-version=false

    Once the app is imported, you will see it listed on the MY APPS page of the App Store. This page will list all the applications that you own. Now that the app has been imported successfully, you can update the visibility of the app, view/update app details, run it, or delete the app using the H2O CLI or directly via the MY APPs page.

  4. Access the URL provided on the CLI on a browser window to see your app.

    $ h2o bundle deploy --generate-version=false
    ...
    URL https://22222222-3333-4444-5555-666666666666.cloud.h2o.ai
  5. To publish it and make it available to all users, run the following command on the CLI.

    $ h2o app update -v
    note

    For more information, see Updating app visibility

  6. Access the App Store on a browser window.

    You will see that your app is now published on the App Store page and is ready to be used by other users on the platform!

    app-store-screen

Using the GUI

Optionally, you can also run this app using the H2O AI Cloud user interface.

  1. Click MY APPS on the H2O AI Cloud home page.

    my-apps

  2. Click Import New App. You will be prompted to upload your application as a .zip file.

    import-app

  3. At this point you will need to compress your app files and folders and create an app bundle. Navigate to your app's root directory and run h2o bundle (you do not need to have configure the H2O CLI to run this command).

    note

    Alternatively, you can open up the folder that contains your application source code and compress the folder into a .zip file. If you are using MacOS, select the relevant files and folders that you wish to compress individually instead of selecting and compressing the entire /root folder.

  4. Upload the .zip file that you just created and select the required Visibility for the app. You can select PRIVATE when first uploading the app to do some light testing before publishing it to other users.

    • PRIVATE: This setting makes the app visible to only you (the app owner). The app will not be visible or searchable on the App Store.

    • ALL_USERS: This setting makes the app visible on the app store to all users.

    Once the app is imported, you will see it listed on the MY APPS page. This page will list all the applications that you own. Now that the app has been imported successfully, you can update the visibility of the app from here, view/update app details, run it, or delete the app.

  5. At this point, the app is still PRIVATE.

    To publish it to all users, on the MY APPS page, click Visibility.

    update-app-visibility

  6. Select ALL_USERS and click Update.

  7. Next, click on APP STORE on the top navigation pane.

    app-store-screen

    You will see that your app is now published on the App Store page and is ready to be used!

Summary

This tutorial walked you through:

  • Setting up your Wave application bundle
  • Importing and publishing an app using the H2O CLI (recommended option)
  • Importing and publishing an app using the App Store GUI (alternative option)
More resources

You can also check out the following blog post and documentation for more information.