inoki-giskard commited on
Commit
e7aeb95
1 Parent(s): 4708837
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,10 +1,23 @@
1
  import gradio as gr
2
  import asyncio
3
  from giskard.ml_worker.ml_worker import MLWorker
 
 
 
4
 
5
  def run_ml_worker(url, api_key, hf_token):
6
  # Always run an external ML worker
7
- ml_worker = MLWorker(False, url, api_key, hf_token)
 
 
 
 
 
 
 
 
 
 
8
  asyncio.get_event_loop().run_until_complete(ml_worker.start())
9
  return "ML worker finished its work"
10
 
 
1
  import gradio as gr
2
  import asyncio
3
  from giskard.ml_worker.ml_worker import MLWorker
4
+ from pydantic import AnyHttpUrl
5
+ from giskard.settings import settings
6
+ from urllib.parse import urlparse
7
 
8
  def run_ml_worker(url, api_key, hf_token):
9
  # Always run an external ML worker
10
+ parsed_url = urlparse(url)
11
+ backend_url = AnyHttpUrl(
12
+ url=f"{parsed_url.scheme if parsed_url.scheme else 'http'}://{parsed_url.hostname}"
13
+ f":{parsed_url.port if parsed_url.port else settings.ws_port}"
14
+ f"/{parsed_url.path if parsed_url.path and len(parsed_url.path) else settings.ws_path}",
15
+ scheme=parsed_url.scheme,
16
+ host=parsed_url.hostname,
17
+ port=parsed_url.port if parsed_url.port else settings.ws_port,
18
+ path=parsed_url.path if parsed_url.path and len(parsed_url.path) else settings.ws_path,
19
+ )
20
+ ml_worker = MLWorker(False, backend_url, api_key, hf_token)
21
  asyncio.get_event_loop().run_until_complete(ml_worker.start())
22
  return "ML worker finished its work"
23