From da4bcb732faaf382d1c015665912db92e91fde16 Mon Sep 17 00:00:00 2001 From: Ruifeng Zheng Date: Mon, 25 Nov 2024 19:30:43 +0800 Subject: [PATCH] [MINOR][PYTHON] Remove some unused third-party library imports ### What changes were proposed in this pull request? Remove some unused third-part library imports ### Why are the changes needed? these imports are never used ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? ci ### Was this patch authored or co-authored using generative AI tooling? no Closes #48954 from zhengruifeng/fix_has_numpy. Authored-by: Ruifeng Zheng Signed-off-by: Ruifeng Zheng --- python/pyspark/sql/connect/session.py | 7 ------- python/pyspark/sql/pandas/types.py | 5 +---- python/pyspark/sql/session.py | 6 ------ 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/python/pyspark/sql/connect/session.py b/python/pyspark/sql/connect/session.py index bfd79092ccf4d..2d544f3f0eca7 100644 --- a/python/pyspark/sql/connect/session.py +++ b/python/pyspark/sql/connect/session.py @@ -113,13 +113,6 @@ from pyspark.sql.connect.shell.progress import ProgressHandler from pyspark.sql.connect.datasource import DataSourceRegistration -try: - import memory_profiler # noqa: F401 - - has_memory_profiler = True -except Exception: - has_memory_profiler = False - class SparkSession: # The active SparkSession for the current thread diff --git a/python/pyspark/sql/pandas/types.py b/python/pyspark/sql/pandas/types.py index 648af21502864..d65126bb3db9e 100644 --- a/python/pyspark/sql/pandas/types.py +++ b/python/pyspark/sql/pandas/types.py @@ -53,14 +53,11 @@ ) from pyspark.errors import PySparkTypeError, UnsupportedOperationException, PySparkValueError from pyspark.loose_version import LooseVersion -from pyspark.sql.utils import has_numpy - -if has_numpy: - import numpy as np if TYPE_CHECKING: import pandas as pd import pyarrow as pa + import numpy as np from pyspark.sql.pandas._typing import SeriesLike as PandasSeriesLike from pyspark.sql.pandas._typing import DataFrameLike as PandasDataFrameLike diff --git a/python/pyspark/sql/session.py b/python/pyspark/sql/session.py index e97b844564100..e35a1cc82d795 100644 --- a/python/pyspark/sql/session.py +++ b/python/pyspark/sql/session.py @@ -90,12 +90,6 @@ from pyspark.sql.connect.client import SparkConnectClient from pyspark.sql.connect.shell.progress import ProgressHandler -try: - import memory_profiler # noqa: F401 - - has_memory_profiler = True -except Exception: - has_memory_profiler = False __all__ = ["SparkSession"]