From 7bc2b2616ac4848f571659629932dfd849013bd9 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Wed, 18 Dec 2024 06:53:04 +0100 Subject: [PATCH] Improve the error message --- python/hopsworks_common/connection.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/hopsworks_common/connection.py b/python/hopsworks_common/connection.py index ea9b756e4..71efab090 100644 --- a/python/hopsworks_common/connection.py +++ b/python/hopsworks_common/connection.py @@ -17,6 +17,7 @@ import importlib import importlib.util +import logging import os import re import sys @@ -52,6 +53,9 @@ _hsfs_engine_type = None +_logger = logging.getLogger(__name__) + + class Connection: """A hopsworks connection object. @@ -434,11 +438,11 @@ def _provide_project(self, name=None): # istio client, default resources,... self._model_serving_api.load_default_configuration() except RestAPIError as e: - if e.response.error_code == 403: + if e.response.error_code == 403 and e.error_code == 320004: print( - "You lack permission to initialize model serving. Machine learning functionality will be not available." + 'API key does not include "SERVING" scope, the related functionality will be disabled.' ) - print("The permission-related exception is:", e) + _logger.debug(f"The ignored exception: {e}") else: raise e