Repository: mars-project/mars

Issue:
[BUG] Ray storage case failed for Ray 1.3.0
<!--
Thank you for your contribution!

Please review https://github.com/mars-project/mars/blob/master/CONTRIBUTING.rst before opening an issue.
-->

**Describe the bug**

Ray storage case failed for Ray 1.3.0 .

Error message:

```
__________________________ test_base_operations[ray] ___________________________

storage_context = <mars.storage.ray.RayStorage object at 0x7fe06827c280>

    @pytest.mark.asyncio
    @require_lib
    async def test_base_operations(storage_context):
        storage = storage_context
    
        data1 = np.random.rand(10, 10)
        put_info1 = await storage.put(data1)
        get_data1 = await storage.get(put_info1.object_id)
        np.testing.assert_array_equal(data1, get_data1)
    
        info1 = await storage.object_info(put_info1.object_id)
        assert info1.size == put_info1.size
    
        data2 = pd.DataFrame({'col1': np.arange(10),
                              'col2': [f'str{i}' for i in range(10)],
                              'col3': np.random.rand(10)},)
        put_info2 = await storage.put(data2)
        get_data2 = await storage.get(put_info2.object_id)
        pd.testing.assert_frame_equal(data2, get_data2)
    
        info2 = await storage.object_info(put_info2.object_id)
        assert info2.size == put_info2.size
    
        # FIXME: remove when list functionality is ready for vineyard.
        if not isinstance(storage, (VineyardStorage, SharedMemoryStorage, RayStorage)):
            num = len(await storage.list())
            assert num == 2
            await storage.delete(info2.object_id)
    
        # test SparseMatrix
        s1 = sps.csr_matrix([[1, 0, 1], [0, 0, 1]])
        s = SparseNDArray(s1)
        put_info3 = await storage.put(s)
        get_data3 = await storage.get(put_info3.object_id)
        assert isinstance(get_data3, SparseMatrix)
        np.testing.assert_array_equal(get_data3.toarray(), s1.A)
        np.testing.assert_array_equal(get_data3.todense(), s1.A)
    
        # test writer and reader
        t = np.random.random(10)
        b = dataserializer.dumps(t)
        async with await storage.open_writer(size=len(b)) as writer:
            split = len(b) // 2
            await writer.write(b[:split])
>           await writer.write(b[split:])

mars/storage/tests/test_libs.py:174: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mars/lib/aio/file.py:56: in __aexit__
    await self.close()
mars/lib/aio/base.py:25: in method
    return await self._loop.run_in_executor(self._executor, func)
../../../miniconda/envs/test/lib/python3.8/concurrent/futures/thread.py:57: in run
    result = self.fn(*self.args, **self.kwargs)
mars/storage/core.py:110: in close
    self._write_close()
mars/storage/ray.py:76: in _write_close
    worker.core_worker.put_file_like_object(metadata, self._buffer.tell(), self._buffer,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   TypeError: put_file_like_object() takes exactly 5 positional arguments (4 given)

python/ray/_raylet.pyx:1032: TypeError
```


Discussion:

Resolving patch:
diff --git a/mars/storage/ray.py b/mars/storage/ray.py
--- a/mars/storage/ray.py
+++ b/mars/storage/ray.py
@@ -73,8 +73,12 @@ def write(self, content: bytes):
     def _write_close(self):
         worker = ray.worker.global_worker
         metadata = ray.ray_constants.OBJECT_METADATA_TYPE_RAW
-        worker.core_worker.put_file_like_object(metadata, self._buffer.tell(), self._buffer,
-                                                self._object_id)
+        args = [metadata, self._buffer.tell(), self._buffer, self._object_id]
+        try:
+            worker.core_worker.put_file_like_object(*args)
+        except TypeError:
+            args.append(None)  # owner_address for ray >= 1.3.0
+            worker.core_worker.put_file_like_object(*args)
 
     def _read_close(self):
         pass


Test patch: