AlenkaF commented on code in PR #14343:
URL: https://github.com/apache/arrow/pull/14343#discussion_r993046065


##########
python/pyarrow/tests/test_plasma.py:
##########
@@ -1071,3 +1075,20 @@ def test_store_capacity():
     with plasma.start_plasma_store(plasma_store_memory=10000) as (name, p):
         plasma_client = plasma.connect(name)
         assert plasma_client.store_capacity() == 10000
+
+
[email protected]
+def test_plasma_deprecated():
+    import pyarrow.plasma as plasma
+
+    with pytest.warns(DeprecationWarning):
+        plasma_store_ctx = plasma.start_plasma_store(
+            plasma_store_memory=10 ** 8,
+            use_valgrind=os.getenv("PLASMA_VALGRIND") == "1")
+        plasma_store_name, _ = plasma_store_ctx.__enter__()

Review Comment:
   So, if running your code exactly:
   ```python
       with pytest.warns(DeprecationWarning):
           plasma_store_ctx = plasma.start_plasma_store(
               plasma_store_memory=10 ** 8,
               use_valgrind=os.getenv("PLASMA_VALGRIND") == "1")
       
       with plasma_store_name, _ as plasma_store_ctx:
           with pytest.warns(DeprecationWarning):
               plasma.connect(plasma_store_name)
   ```
   I get:
   ```python
           with pytest.warns(DeprecationWarning):
   >           plasma_store_ctx = plasma.start_plasma_store(
                   plasma_store_memory=10 ** 8,
                   use_valgrind=os.getenv("PLASMA_VALGRIND") == "1")
   E           Failed: DID NOT WARN. No warnings of type (<class 
'DeprecationWarning'>,) were emitted. The list of emitted warnings is: [].
   
   python/pyarrow/tests/test_plasma.py:1085: Failed
   ```
   
   This seems connected to what Joris already explained in 
https://github.com/apache/arrow/pull/14343#discussion_r992011018. 
   
   So I try `with ...: pass`:
   ```python
       plasma_store_ctx = plasma.start_plasma_store(
           plasma_store_memory=10 ** 8,
           use_valgrind=os.getenv("PLASMA_VALGRIND") == "1")
       
       with pytest.warns(DeprecationWarning):
           with plasma_store_ctx:
               pass
       
       with plasma_store_name, _ as plasma_store_ctx:
           with pytest.warns(DeprecationWarning):
               plasma.connect(plasma_store_name)
   ```
   and the first part works but then I get a an error on the second:
   ```python
           with pytest.warns(DeprecationWarning):
               with plasma_store_ctx:
                   pass
       
   >       with plasma_store_name, _ as plasma_store_ctx:
   E       NameError: name 'plasma_store_name' is not defined
   
   python/pyarrow/tests/test_plasma.py:1092: NameError
   ```
   
   So my first thought is to change the order in the erroring `with` statement 
to 
   ```python
   with plasma_store_ctx as plasma_store_name, _ :
   ```
   but it gives and `AttributeError:args` from `contextlib` `__enter__` 
function. So I came to this point that works but I am not sure if it is well 
written:
   
   ```python
       plasma_store_ctx = plasma.start_plasma_store(
           plasma_store_memory=10 ** 8,
           use_valgrind=os.getenv("PLASMA_VALGRIND") == "1")
       
       with pytest.warns(DeprecationWarning):
           with plasma_store_ctx:
               pass
       
       plasma_store_ctx = plasma.start_plasma_store(
           plasma_store_memory=10 ** 8,
           use_valgrind=os.getenv("PLASMA_VALGRIND") == "1")
   
       with plasma_store_ctx as tmp:
           plasma_store_name, _ =tmp
           with pytest.warns(DeprecationWarning):
               plasma.connect(plasma_store_name)
   ````
   
   there is not `__enter__` call without `__exit__` as I use `with` on 
`plasma_store_ctx`  but I do need to initiate `start_plasma_store` twice.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to