Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

main.py 785 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  1. import logging
  2. from fastapi import BackgroundTasks, FastAPI, Request
  3. from . import datamodel
  4. from . import relaxml
  5. app = FastAPI()
  6. relax = relaxml.RelaxML()
  7. @app.on_event('startup')
  8. def startup():
  9. logging.basicConfig(format='%(levelname)s:\t %(message)s', level=logging.INFO)
  10. @app.post('/predict')
  11. async def predict(request: Request, background_tasks: BackgroundTasks):
  12. data = await request.json()
  13. tasks = [datamodel.Task(t) for t in data.get('tasks', [])]
  14. background_tasks.add_task(relax.predict, tasks)
  15. return []
  16. @app.get('/')
  17. @app.get('/health')
  18. def health():
  19. return {
  20. 'status': 'UP',
  21. 'v2': False
  22. }
  23. @app.post('/setup')
  24. def setup(data: datamodel.Setup):
  25. relax.setup(data)
  26. return { 'model_version': relax.model_version }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...