From c2843eead34ace58848cef79ab27f71672a9a79b Mon Sep 17 00:00:00 2001 From: Tim Reichard Date: Tue, 12 Mar 2024 15:26:49 -0500 Subject: [PATCH] Avoid instantiating spark if databricks-connect installed --- HISTORY.rst | 5 +++++ aioradio/ds_utils.py | 7 ++++++- setup.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 5c4c4cb..adaf059 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,11 @@ History ======= +v0.20.12 (2024-03-12) + +* Avoid instantiating spark if databricks-connect installed. + + v0.20.11 (2024-03-12) * Add pyspark back in as install requirement. diff --git a/aioradio/ds_utils.py b/aioradio/ds_utils.py index cce1068..6497ec2 100644 --- a/aioradio/ds_utils.py +++ b/aioradio/ds_utils.py @@ -10,6 +10,8 @@ # pylint: disable=too-many-boolean-expressions # pylint: disable=unnecessary-comprehension # pylint: disable=unused-argument +# pylint: disable=unused-import +# pylint: disable=used-before-assignment import base64 import csv @@ -46,7 +48,10 @@ c_handler.setFormatter(c_format) logger.addHandler(c_handler) -spark = SparkSession.builder.getOrCreate() +try: + from databricks.connect import DatabricksSession +except ImportError: + spark = SparkSession.builder.getOrCreate() ############################### Databricks functions ################################ diff --git a/setup.py b/setup.py index 17122a9..ee0b699 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ long_description = fileobj.read() setup(name='aioradio', - version='0.20.11', + version='0.20.12', description='Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more', long_description=long_description, long_description_content_type="text/markdown",