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

orchestrator.py 789 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
  1. #!/usr/bin/env python3
  2. from model import DagsHubLSModel
  3. from flask import Flask, request
  4. import cloudpickle
  5. import requests
  6. import docker
  7. import shutil
  8. import time
  9. CURRENT_PORT = 9091
  10. client = docker.from_env()
  11. app = Flask(__name__)
  12. portmap = {}
  13. @app.post('/configure')
  14. def initialize_hooks():
  15. global CURRENT_PORT
  16. ## start a new instance of the image
  17. portmap[CURRENT_PORT] = client.containers.run('configurable-ls-backend', ports={f'9090/tcp': str(CURRENT_PORT)}, detach=True)
  18. time.sleep(10)
  19. ## configure the model
  20. requests.post(f'http://127.0.0.1:{CURRENT_PORT}/configure',
  21. headers=request.headers,
  22. json=request.json)
  23. CURRENT_PORT += 1
  24. ## return link
  25. return f'Port Forward: http://127.0.0.1:{CURRENT_PORT - 1}/'
Tip!

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

Comments

Loading...