Skip to content

Commit

Permalink
Add configuration values for cellsam server.
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbar committed Dec 19, 2023
1 parent 8673c41 commit 5fefbb8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
11 changes: 6 additions & 5 deletions backend/deepcell_label/client.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 4 additions & 0 deletions backend/deepcell_label/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5fefbb8

Please sign in to comment.