From 27f36daa56f405cb48f33571f80bc94c14aa56b7 Mon Sep 17 00:00:00 2001 From: Paul Donnelly Date: Sun, 29 Sep 2024 14:56:21 -0500 Subject: [PATCH] fixes 5738 --- py-scoring/src/ai/h2o/sparkling/Initializer.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/py-scoring/src/ai/h2o/sparkling/Initializer.py b/py-scoring/src/ai/h2o/sparkling/Initializer.py index 4296d3c825..abdd24e497 100644 --- a/py-scoring/src/ai/h2o/sparkling/Initializer.py +++ b/py-scoring/src/ai/h2o/sparkling/Initializer.py @@ -159,8 +159,9 @@ def __get_sw_jar(sc): if zipfile.is_zipfile(packagePath): return Initializer.__extracted_jar_path(sc) else: - from pkg_resources import resource_filename - return os.path.abspath(resource_filename("sparkling_water", BackingJar.getName())) + import importlib.resources as resources + with resources.path("sparkling_water", BackingJar.getName()) as jar_path: + return jar_path.resolve() @staticmethod def __get_logger(jvm): @@ -192,11 +193,11 @@ def __add_url_to_classloader(gateway, url): @staticmethod def isRunningViaDBCConnect(): - import pkg_resources as pkg try: - pkg.get_distribution('databricks-connect') - return True - except: + from importlib.util import find_spec + spec = find_spec('databricks.connect') + return spec is not None + except ImportError: return False @staticmethod