diff --git a/bioimageio_colab/register_sam_service.py b/bioimageio_colab/register_sam_service.py index cf2d12f..ecf977d 100644 --- a/bioimageio_colab/register_sam_service.py +++ b/bioimageio_colab/register_sam_service.py @@ -204,33 +204,11 @@ async def register_service(args: dict) -> None: if not workspace_token: raise ValueError("Workspace token is required to connect to the Hypha server.") - # Wait until the client ID is available - test_client = await connect_to_server( - { - "server_url": args.server_url, - "workspace": args.workspace_name, - "token": workspace_token, - } - ) - colab_client_id = f"{args.workspace_name}/{args.client_id}" - n_failed_attempts = 0 - waiting_for_client = True - while waiting_for_client: - all_clients = await test_client.list_clients() - waiting_for_client = any([colab_client_id == client["id"] for client in all_clients]) - if waiting_for_client: - n_failed_attempts += 1 - logger.info( - f"Waiting for client ID '{colab_client_id}' to be available... (attempt {n_failed_attempts})" - ) - await asyncio.sleep(1) - - # Connect to the workspace + # Connect to the workspace (with random client ID) colab_client = await connect_to_server( { "server_url": args.server_url, "workspace": args.workspace_name, - "client_id": args.client_id, "name": "SAM Server", "token": workspace_token, } @@ -266,14 +244,13 @@ async def register_service(args: dict) -> None: # - True if the embedding was removed successfully # - False if the user was not found in the cache "clear_cache": partial(clear_cache, embedding_cache), - }, - {"overwrite": True}, + } ) sid = service_info["id"] - assert sid == f"{args.workspace_name}/{args.client_id}:{args.service_id}" + client_service = sid.split("/")[1] logger.info(f"Registered service with ID: {sid}") logger.info( - f"Test the service here: {args.server_url}/{args.workspace_name}/services/{args.client_id}:{args.service_id}/hello" + f"Test the service here: {args.server_url}/{args.workspace_name}/services/{client_service}/hello" ) @@ -291,14 +268,9 @@ async def register_service(args: dict) -> None: parser.add_argument( "--workspace_name", default="bioimageio-colab", help="Name of the workspace" ) - parser.add_argument( - "--client_id", - default="kubernetes", - help="Client ID for registering the service", - ) parser.add_argument( "--service_id", - default="sam", + default="microsam", help="Service ID for registering the service", ) parser.add_argument( diff --git a/docker-compose.yml b/docker-compose.yml index 90879cb..c3c8a18 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,5 @@ services: command: [ "--server_url=https://hypha.aicell.io", "--workspace_name=bioimageio-colab", - "--client_id=kubernetes", "--service_id=sam", ] diff --git a/test/test_model_service.py b/test/test_model_service.py index d1decae..c64a867 100644 --- a/test/test_model_service.py +++ b/test/test_model_service.py @@ -5,12 +5,11 @@ SERVER_URL = "https://hypha.aicell.io" WORKSPACE_NAME = "bioimageio-colab" -CLIENT_ID = "kubernetes" SERVICE_ID = "sam" def test_service_available(): - service_url = f"{SERVER_URL}/{WORKSPACE_NAME}/services/{CLIENT_ID}:{SERVICE_ID}/hello" + service_url = f"{SERVER_URL}/{WORKSPACE_NAME}/services/*:{SERVICE_ID}/hello" response = requests.get(service_url) assert response.status_code == 200 assert response.json() == "Welcome to the Interactive Segmentation service!" @@ -19,8 +18,8 @@ def test_get_service(): client = connect_to_server({"server_url": SERVER_URL, "method_timeout": 5}) assert client - sid = f"{WORKSPACE_NAME}/{CLIENT_ID}:{SERVICE_ID}" - segment_svc = client.get_service(sid) + sid = f"{WORKSPACE_NAME}/*:{SERVICE_ID}" + segment_svc = client.get_service(sid, {"mode": "random"}) assert segment_svc.id == sid assert segment_svc.config.workspace == WORKSPACE_NAME assert segment_svc.get("segment")