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
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')
TLDR: See how to run the Wave server manually.
Detailed answer:
If you look at architecture, you will notice there are actually 2 servers:
The reason why
wave run foo
works anduvicorn foo:main
does not is simply becausewave 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.