Skip to content

Commit

Permalink
Protect RequestService until eval is in stack.
Browse files Browse the repository at this point in the history
Protect general execution of RequestService manager class to still be
usable even without the evaluation service being online in the Docker
stack.
  • Loading branch information
robertbartel authored and christophertubbs committed Sep 19, 2023
1 parent 0a8e12b commit 9bd8044
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions python/services/requestservice/dmod/requestservice/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,18 @@ def __init__(self, listen_host='',
service_host=data_service_host,
service_port=int(data_service_port),
service_ssl_dir=self.data_service_ssl_dir)

self._evaluation_service_handler = EvaluationRequestHandler(
target_service='evaluation-service',
service_host=evaluation_service_host,
service_port=evaluation_service_port,
ssl_directory=evaluation_service_ssl_dir
)
# This probably won't work until evaluation service is properly added in Docker stack, so wrap in try for now
try:
self._evaluation_service_handler = EvaluationRequestHandler(
target_service='evaluation-service',
service_host=evaluation_service_host,
service_port=evaluation_service_port,
ssl_directory=evaluation_service_ssl_dir
)
self._eval_handler_exception = None
except Exception as e:
self._evaluation_service_handler = None
self._eval_handler_exception = e

@property
def session_manager(self):
Expand All @@ -170,6 +175,10 @@ async def listener(self, websocket: WebSocketServerProtocol, path):
event_type = MessageEventType.INVALID if req_message is None else req_message.get_message_event_type()

if isinstance(req_message, LaunchEvaluationMessage) or isinstance(req_message, OpenEvaluationMessage):
if self._evaluation_service_handler is None:
msg = (f"{self.__class__.__name__} could not initialize evaluation handler due to "
f"{self._eval_handler_exception.__class__.__name__}: {self._eval_handler_exception!s}")
raise RuntimeError(msg)
response = await self._evaluation_service_handler.handle_request(
request=req_message,
socket=websocket,
Expand Down

0 comments on commit 9bd8044

Please sign in to comment.