[Feature Request] Uvicorn integration
See original GitHub issue🚀 Feature Request
Firstly thank you for open sourcing this - documentation is excellent too!.
Motivation
Often ASGI/WSGI python webserver frameworks are launched with their own wrapper module such as gunicorn, uvicorn and hypercorn.
Example as per the uvicorn quickstart guide.
(note the run command: uvicorn example:app
)
The uvicorn command then runs this main module.
If one wishes to use hydra for configuration management in the uvicorn examples they would need to rewrite some code from the above module perhaps:
import hydra
from uvicorn.supervisors import Multiprocess
from uvicorn.config import Config
from uvicorn.main import Server
async def app(scope, receive, send):
assert scope['type'] == 'http'
await send({
'type': 'http.response.start',
'status': 200,
'headers': [
[b'content-type', b'text/plain'],
]
})
await send({
'type': 'http.response.body',
'body': b'Hello, world!',
})
@hydra.main()
def run(cfg):
print(cfg.pretty())
config = Config(app)
server = Server(config=config)
sock = config.bind_socket()
supervisor = Multiprocess(config)
supervisor.run(server.run, sockets=[sock])
if __name__ == "__main__":
run()
Pitch
Describe the solution you’d like
A very open ended question but what are peoples thoughts on developing a way to make these libraries work together
Goals:
- users don’t have to duplicate code.
- make it easier to pass the hydra configuration into the uvicorn application
Are you willing to open a pull request?
- Yes
cc. @tomchristie
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Uvicorn
Uvicorn is an ASGI web server implementation for Python. Until recently Python has lacked a minimal low-level server/application interface for async frameworks.
Read more >Building REST APIs using FastAPI, SQLAlchemy & Uvicorn
Integrate FastAPI with SQLAlchemy; Using both normal and async ways of handling requests. Using Swagger in FastAPI. If you would like to refer ......
Read more >Uvicorn - New Relic Documentation
Uvicorn. Read about the requirements and tips for integrating our Python agent with an app that uses the ASGI server Uvicorn.
Read more >How to start a Uvicorn + FastAPI in background when testing ...
app = App() self.proc = Process(target=uvicorn.run, args=(app.api,), ... pytest import requests import uvicorn from fastapi import FastAPI ...
Read more >Python feature server - Feast
This enables users to write and read features from the online store using any programming language that can make HTTP requests. CLI.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@omry - Thanks for your detailed responses - appreciate it.
Yes agree #219 - looks interesting - will keep an eye out and try this when available.
Thanks very much for the example - that’s a neat way of integrating uvicorn and hydra!
Closing, this should be possible via the compose API or following the example I pointed to.