From 04278fb45fc15c426bcba8a4c6f771cd8dc16b3e Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Mon, 16 Dec 2024 07:29:52 +0100 Subject: [PATCH] Catch HSML initialization permission-related errors in login --- python/hopsworks_common/connection.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/hopsworks_common/connection.py b/python/hopsworks_common/connection.py index e8b5583e2..ea9b756e4 100644 --- a/python/hopsworks_common/connection.py +++ b/python/hopsworks_common/connection.py @@ -25,6 +25,7 @@ from typing import Any, Optional from hopsworks_common import client, constants, usage, util, version +from hopsworks_common.client.exceptions import RestAPIError from hopsworks_common.core import ( hosts_api, project_api, @@ -429,7 +430,17 @@ def _provide_project(self, name=None): if self._variable_api.get_data_science_profile_enabled(): # load_default_configuration has to be called before using hsml # but after a project is provided to client - self._model_serving_api.load_default_configuration() # istio client, default resources,... + try: + # istio client, default resources,... + self._model_serving_api.load_default_configuration() + except RestAPIError as e: + if e.response.error_code == 403: + print( + "You lack permission to initialize model serving. Machine learning functionality will be not available." + ) + print("The permission-related exception is:", e) + else: + raise e def close(self) -> None: """Close a connection gracefully.