0

I want to run h2o wave with uvicorn command.

in public document (https://wave.h2o.ai/docs/deployment) says wave run foo == uvicorn foo:main

but in my pycharm terminal, "wave run foo" works but not "uvicorn foo:main" like below

wave run command enter image description here

uvicorn foo:main command enter image description here

what is problem??

foo.py code

from h2o_wave import site, ui, Q, app, main
import logging

logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s')
_localhost = "0.0.0.0"
def _scan_free_port(port = "8000"):
    return port
@app('/demo')
async def serve(q: Q):
    logging.warning('All your base are belong to us')

lib version below

  • h2o-wave 0.20.0

  • starlette 0.13.8

  • uvicorn 0.12.2

  • httpcore 0.12.3

  • httpx 0.16.1

  • Python 3.7.5

ps. in FUTURE, I want to run like below

import uvicorn
if __name__ == '__main__':
    uvicorn.run('foo:main')
H Sung
  • 31
  • 2

1 Answers1

0

TLDR: See how to run the Wave server manually.

Detailed answer:

If you look at architecture, you will notice there are actually 2 servers:

  1. Python server - Wave app, the one you are running via uvicorn.
  2. Wave server - Go server that acts as a proxy between Wave app and browser.

The reason why wave run foo works and uvicorn foo:main does not is simply because wave run spawns Wave server under the hood. For deployment though, it's recommended to start both Wave server and Wave app separately to allow for the most flexible configuration.

MartinT
  • 590
  • 5
  • 21