Skip to content

Commit a22eb78

Browse files
authored
Fail if loading fails (#163)
* Fail if loading fails * trying to bring down the server * Stop the server when load fails * Remove empty files
1 parent b6d3b28 commit a22eb78

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ RUN curl -sSL https://install.python-poetry.org | python -
55
ENV PATH="/root/.local/bin:${PATH}"
66
COPY . .
77

8-
RUN poetry install --no-dev
8+
RUN poetry install --only main

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "truss"
3-
version = "0.1.11"
3+
version = "0.1.12"
44
description = "A seamless bridge from model development to model delivery"
55
license = "MIT"
66
readme = "README.md"

truss/templates/server/common/truss_server.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,15 @@ def __init__(self, *args, **kwargs):
168168
super().__init__(*args, **kwargs)
169169
_configure_logging()
170170

171-
def load_all(self):
172-
for model in self.registered_models.get_models():
173-
model.load()
171+
def load_all(self, main_loop):
172+
try:
173+
for model in self.registered_models.get_models():
174+
model.load()
175+
except Exception as e:
176+
logging.error(f"Error loading model: {e}")
177+
self._http_server.stop()
178+
main_loop.stop()
179+
raise e
174180

175181
def start(self, models: List[KFModel], nest_asyncio: bool = False):
176182
if len(models) != 1:
@@ -194,7 +200,10 @@ def start(self, models: List[KFModel], nest_asyncio: bool = False):
194200
logging.info("Will fork %d workers", self.workers)
195201
self._http_server.start(self.workers)
196202

197-
Thread(target=self.load_all).start()
203+
Thread(
204+
target=self.load_all,
205+
args=[IOLoop.current()],
206+
).start()
198207

199208
IOLoop.current().start()
200209

0 commit comments

Comments
 (0)