You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2022/03/21 02:26:49 UTC

[spark] branch branch-3.3 updated: Revert "[SPARK-38556][PYTHON] Disable Pandas usage logging for method calls inside @contextmanager functions"

This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new 1a720d3  Revert "[SPARK-38556][PYTHON] Disable Pandas usage logging for method calls inside @contextmanager functions"
1a720d3 is described below

commit 1a720d30f77a8b63fe484c60fc4f4953f9ff1af8
Author: Hyukjin Kwon <gu...@apache.org>
AuthorDate: Mon Mar 21 11:23:01 2022 +0900

    Revert "[SPARK-38556][PYTHON] Disable Pandas usage logging for method calls inside @contextmanager functions"
    
    This reverts commit c284faad2d7d3b813c1c94c612b814c129b6dad3.
---
 python/pyspark/instrumentation_utils.py | 30 ------------------------------
 1 file changed, 30 deletions(-)

diff --git a/python/pyspark/instrumentation_utils.py b/python/pyspark/instrumentation_utils.py
index b9aacf6..908f5cb 100644
--- a/python/pyspark/instrumentation_utils.py
+++ b/python/pyspark/instrumentation_utils.py
@@ -21,7 +21,6 @@ import inspect
 import threading
 import importlib
 import time
-from contextlib import AbstractContextManager
 from types import ModuleType
 from typing import Tuple, Union, List, Callable, Any, Type
 
@@ -31,24 +30,6 @@ __all__: List[str] = []
 _local = threading.local()
 
 
-class _WrappedAbstractContextManager(AbstractContextManager):
-    def __init__(
-        self, acm: AbstractContextManager, class_name: str, function_name: str, logger: Any
-    ):
-        self._enter_func = _wrap_function(
-            class_name, "{}.__enter__".format(function_name), acm.__enter__, logger
-        )
-        self._exit_func = _wrap_function(
-            class_name, "{}.__exit__".format(function_name), acm.__exit__, logger
-        )
-
-    def __enter__(self):  # type: ignore[no-untyped-def]
-        return self._enter_func()
-
-    def __exit__(self, exc_type, exc_val, exc_tb):  # type: ignore[no-untyped-def]
-        return self._exit_func(exc_type, exc_val, exc_tb)
-
-
 def _wrap_function(class_name: str, function_name: str, func: Callable, logger: Any) -> Callable:
 
     signature = inspect.signature(func)
@@ -63,17 +44,6 @@ def _wrap_function(class_name: str, function_name: str, func: Callable, logger:
             start = time.perf_counter()
             try:
                 res = func(*args, **kwargs)
-                if isinstance(res, AbstractContextManager):
-                    # Wrap AbstractContextManager's subclasses returned by @contextmanager decorator
-                    # function so that wrapped function calls inside __enter__ and __exit__
-                    # are not recorded by usage logger.
-                    #
-                    # The reason to add a wrapped class after function calls instead of
-                    # wrapping __enter__ and __exit__ methods of _GeneratorContextManager class is
-                    # because usage logging should be disabled for functions with @contextmanager
-                    # decorator in PySpark only.
-                    res = _WrappedAbstractContextManager(res, class_name, function_name, logger)
-
                 logger.log_success(
                     class_name, function_name, time.perf_counter() - start, signature
                 )

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org