HyukjinKwon commented on code in PR #47009:
URL: https://github.com/apache/spark/pull/47009#discussion_r1645242054


##########
python/pyspark/errors/utils.py:
##########
@@ -165,8 +165,37 @@ def _capture_call_site(spark_session: "SparkSession", 
depth: int) -> str:
     in the user code that led to the error.
     """
     stack = list(reversed(inspect.stack()))
+    ipython = None
+
+    # We try import here since IPython is not a required dependency
+    try:
+        from IPython import get_ipython
+
+        ipython = get_ipython()
+    except ImportError:
+        pass
+
+    if ipython:
+        import pyspark
+
+        # Filtering out PySpark code and keeping user code only
+        pyspark_root = os.path.dirname(pyspark.__file__)
+        stack = [
+            frame_info for frame_info in inspect.stack() if pyspark_root not 
in frame_info.filename
+        ]
+
+    depth = int(

Review Comment:
   now this functions take a parameter called `depth` :-).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to