Skip to content

Commit

Permalink
Catch HSML initialization permission-related errors in login
Browse files Browse the repository at this point in the history
  • Loading branch information
aversey committed Dec 16, 2024
1 parent c25ef25 commit 04278fb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion python/hopsworks_common/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 04278fb

Please sign in to comment.