Skip to content

Commit 5f55b68

Browse files
committed
Check for undefined API on exception
(cherry picked from commit e02addc)
1 parent 4d8bde0 commit 5f55b68

File tree

1 file changed

+6
-4
lines changed
  • pkg/workloads/cortex/onnx_serve

1 file changed

+6
-4
lines changed

pkg/workloads/cortex/onnx_serve/api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def get_signature(app_name, api_name):
219219

220220

221221
def start(args):
222+
api = None
222223
try:
223224
ctx = Context(s3_path=args.context, cache_dir=args.cache_dir, workload_id=args.workload_id)
224225
api = ctx.apis_id_map[args.api]
@@ -240,11 +241,12 @@ def start(args):
240241
except CortexException as e:
241242
e.wrap("error")
242243
logger.error(str(e))
243-
logger.exception(
244-
"An error occured starting the api, see `cx logs -v api {}` for more details".format(
245-
api["name"]
244+
if api is not None:
245+
logger.exception(
246+
"An error occured starting the api, see `cx logs -v api {}` for more details".format(
247+
api["name"]
248+
)
246249
)
247-
)
248250
sys.exit(1)
249251

250252
serve(app, listen="*:{}".format(args.port))

0 commit comments

Comments
 (0)