diff --git a/backend/.env.example b/backend/.env.example index 218f5c70..2d0e9503 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -17,3 +17,8 @@ FLASK_ENV=development # Flask monitoring dashboard DASHBOARD_CONFIG=fmd_config.cfg + +# Cellsam server +CELLSAM_IP=127.0.0.1 +CELLSAM_PORT=8765 +CELLSAM_SERVER_VERSION= diff --git a/backend/deepcell_label/client.py b/backend/deepcell_label/client.py index b2430423..435c8e47 100644 --- a/backend/deepcell_label/client.py +++ b/backend/deepcell_label/client.py @@ -1,23 +1,24 @@ import asyncio -import os import pickle import zlib import websockets from flask import current_app +from deepcell_label.config import CELLSAM_IP, CELLSAM_PORT + # connects to cell SAM server async def perform_send(to_send): - uri = os.environ['CELLSAM_SERVER'] # to be replaced with cell SAM server uri + uri = f'ws://{CELLSAM_IP}:{CELLSAM_PORT}' + async with websockets.connect(uri, ping_interval=None) as websocket: data = {'img': to_send} - print(uri) pkt = zlib.compress(pickle.dumps(data)) await websocket.send(pkt) - print('sent') + pkt_received = await websocket.recv() - print('received') + mask = pickle.loads(zlib.decompress(pkt_received)) return mask diff --git a/backend/deepcell_label/config.py b/backend/deepcell_label/config.py index d59e26a0..b787fde3 100644 --- a/backend/deepcell_label/config.py +++ b/backend/deepcell_label/config.py @@ -12,6 +12,10 @@ AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY', default='') S3_BUCKET = config('S3_BUCKET', default='deepcell-label-input') +# Cellsam compute server +CELLSAM_IP = config('CELLSAM_IP', default='') +CELLSAM_PORT = config('CELLSAM_PORT', default='') + TEMPLATES_AUTO_RELOAD = config('TEMPLATES_AUTO_RELOAD', cast=bool, default=True) # SQLAlchemy settings