Skip to content

Commit 2092221

Browse files
gaogaotiantiandongjoon-hyun
authored andcommitted
[SPARK-55407][PYSPARK] Replace logger.warn with logger.warning
### What changes were proposed in this pull request? Replace all `logger.warn` usage with `logger.warning` ### Why are the changes needed? logger.warn is obsolete and should not be used anymore - https://docs.python.org/3/library/logging.html#logging.Logger.warning ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? No behavioral change. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #54190 from gaogaotiantian/fix-warn. Authored-by: Tian Gao <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 56b4a2d commit 2092221

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

python/pyspark/logger/tests/test_logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def test_log_info_with_exception(self):
7171
self.assertTrue("msg" in log_json["exception"])
7272
self.assertTrue("stacktrace" in log_json["exception"])
7373

74-
def test_log_warn(self):
75-
self.logger.warn("This is an warn log", user="test_user_warn", action="test_action_warn")
74+
def test_log_warning(self):
75+
self.logger.warning("This is an warn log", user="test_user_warn", action="test_action_warn")
7676
log_json = json.loads(self.handler.stream.getvalue().strip())
7777

7878
self.assertEqual(log_json["msg"], "This is an warn log")

python/pyspark/sql/connect/client/reattach.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def target() -> None:
212212
with attempt:
213213
self._stub.ReleaseExecute(request, metadata=self._metadata)
214214
except Exception as e:
215-
logger.warn(f"ReleaseExecute failed with exception: {e}.")
215+
logger.warning(f"ReleaseExecute failed with exception: {e}.")
216216

217217
with self._lock:
218218
if self._release_thread_pool_instance is not None:
@@ -239,7 +239,7 @@ def target() -> None:
239239
with attempt:
240240
self._stub.ReleaseExecute(request, metadata=self._metadata)
241241
except Exception as e:
242-
logger.warn(f"ReleaseExecute failed with exception: {e}.")
242+
logger.warning(f"ReleaseExecute failed with exception: {e}.")
243243

244244
with self._lock:
245245
if self._release_thread_pool_instance is not None:

python/pyspark/sql/connect/dataframe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ def _schema(self) -> StructType:
19011901
try:
19021902
self._cached_schema_serialized = CPickleSerializer().dumps(self._schema)
19031903
except Exception as e:
1904-
logger.warn(f"DataFrame schema pickle dumps failed with exception: {e}.")
1904+
logger.warning(f"DataFrame schema pickle dumps failed with exception: {e}.")
19051905
self._cached_schema_serialized = None
19061906
return self._cached_schema
19071907

@@ -1913,7 +1913,7 @@ def schema(self) -> StructType:
19131913
try:
19141914
return CPickleSerializer().loads(self._cached_schema_serialized)
19151915
except Exception as e:
1916-
logger.warn(f"DataFrame schema pickle loads failed with exception: {e}.")
1916+
logger.warning(f"DataFrame schema pickle loads failed with exception: {e}.")
19171917
# In case of pickle ser/de failure, fallback to deepcopy approach.
19181918
return copy.deepcopy(_schema)
19191919

python/pyspark/sql/connect/plan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ def __del__(self) -> None:
733733
metadata = session.client._builder.metadata()
734734
channel(req, metadata=metadata) # type: ignore[arg-type]
735735
except Exception as e:
736-
logger.warn(f"RemoveRemoteCachedRelation failed with exception: {e}.")
736+
logger.warning(f"RemoveRemoteCachedRelation failed with exception: {e}.")
737737

738738

739739
class Hint(LogicalPlan):

python/pyspark/sql/connect/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -943,12 +943,12 @@ def stop(self) -> None:
943943
try:
944944
self.client.release_session()
945945
except Exception as e:
946-
logger.warn(f"session.stop(): Session could not be released. Error: ${e}")
946+
logger.warning(f"session.stop(): Session could not be released. Error: ${e}")
947947

948948
try:
949949
self.client.close()
950950
except Exception as e:
951-
logger.warn(f"session.stop(): Client could not be closed. Error: ${e}")
951+
logger.warning(f"session.stop(): Client could not be closed. Error: ${e}")
952952

953953
if self is SparkSession._default_session:
954954
SparkSession._default_session = None
@@ -964,7 +964,7 @@ def stop(self) -> None:
964964
try:
965965
PySparkSession._activeSession.stop()
966966
except Exception as e:
967-
logger.warn(
967+
logger.warning(
968968
"session.stop(): Local Spark Connect Server could not be stopped. "
969969
f"Error: ${e}"
970970
)

0 commit comments

Comments
 (0)