diff --git a/bioimageio/engine/ray_app_loader.py b/bioimageio/engine/ray_app_loader.py index 9330de2..f9cd584 100644 --- a/bioimageio/engine/ray_app_loader.py +++ b/bioimageio/engine/ray_app_loader.py @@ -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", @@ -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( """ @@ -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__":