Skip to content

Commit

Permalink
replace server_url
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Aug 16, 2024
1 parent 747784b commit 1a82ddb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bioimageio/engine/ray_app_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def export(app_class, config=None):
@serve.deployment
class HyphaApp:
def __init__(self, server_url, workspace, token, services):
self.server_url = server_url
self._services = services
self._hypha_server = connect_to_server({"server_url": "https://hypha.aicell.io", "token": token, "workspace": workspace})
self._hypha_server = connect_to_server({"server_url": server_url, "token": token, "workspace": workspace})
svc = {
"name": "Ray Functions",
"id": "ray-functions",
Expand All @@ -64,12 +65,13 @@ async def service_function(*args, **kwargs):

for service_name, service_bind in self._services.items():
svc[service_name] = create_service_function(service_name, service_bind)

info = self._hypha_server.register_service(svc, {"overwrite":True})
print("Hypha service info:", info)
self.info = info

async def __call__(self, request: Request):
redirect_url = f"https://hypha.aicell.io/{self.info.config.workspace}/services/{self.info.id.split('/')[1]}/translator?text=hello"
redirect_url = f"{self.server_url}/{self.info.config.workspace}/services/{self.info.id.split('/')[1]}/translator?text=hello"
return HTMLResponse(
"""
<html>
Expand Down Expand Up @@ -104,6 +106,8 @@ async def __call__(self, request: Request):
workspace = os.environ.get("HYPHA_WORKSPACE")
token = os.environ.get("HYPHA_TOKEN")

assert server_url, "Server URL is not provided"

app = HyphaApp.bind(server_url, workspace, token, ray_apps)

if __name__ == "__main__":
Expand Down

0 comments on commit 1a82ddb

Please sign in to comment.