mars
mars copied to clipboard
[BUG][pandas 1.4 compatibility issue] Ray executor run test_sample_execution raises ValueError: buffer source array is read-only
Describe the bug A clear and concise description of what the bug is.
export MARS_CI_BACKEND=ray
setup = <mars.deploy.oscar.session.SyncSession object at 0x16fa84430>
def test_sample_execution(setup):
rs = np.random.RandomState(0)
# test dataframe
raw_df = pd.DataFrame(rs.rand(100, 5), columns=["c1", "c2", "c3", "c4", "c5"])
# test single chunk
df = md.DataFrame(raw_df)
r = df.sample(10, random_state=rs)
pd.testing.assert_frame_equal(
r.execute().fetch(), raw_df.sample(10, random_state=rs)
)
r = df.sample(frac=0.1, weights="c1", random_state=rs)
pd.testing.assert_frame_equal(
r.execute().fetch(), raw_df.sample(frac=0.1, weights="c1", random_state=rs)
)
r = df.sample(10, weights=df["c2"], random_state=rs)
pd.testing.assert_frame_equal(
r.execute().fetch(), raw_df.sample(10, weights=raw_df["c2"], random_state=rs)
)
# test multinomial tile & execution
df = md.DataFrame(raw_df, chunk_size=13)
r1 = df.sample(10, replace=True, random_state=rs)
r2 = df[:].sample(10, replace=True, random_state=rs)
pd.testing.assert_frame_equal(r1.execute().fetch(), r2.execute().fetch())
r1 = df.sample(frac=0.1, weights="c2", always_multinomial=True, random_state=rs)
r2 = df[:].sample(frac=0.1, weights="c2", always_multinomial=True, random_state=rs)
> pd.testing.assert_frame_equal(r1.execute().fetch(), r2.execute().fetch())
mars/dataframe/indexing/tests/test_indexing_execution.py:1573:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
mars/core/entity/tileables.py:462: in execute
result = self.data.execute(session=session, **kw)
mars/core/entity/executable.py:144: in execute
return execute(self, session=session, **kw)
mars/deploy/oscar/session.py:1888: in execute
return session.execute(
mars/deploy/oscar/session.py:1682: in execute
execution_info: ExecutionInfo = fut.result(
../../.pyenv/versions/3.8.13/lib/python3.8/concurrent/futures/_base.py:444: in result
return self.__get_result()
../../.pyenv/versions/3.8.13/lib/python3.8/concurrent/futures/_base.py:389: in __get_result
raise self._exception
mars/deploy/oscar/session.py:1868: in _execute
await execution_info
../../.pyenv/versions/3.8.13/lib/python3.8/asyncio/tasks.py:695: in _wrap_awaitable
return (yield from awaitable.__await__())
mars/deploy/oscar/session.py:105: in wait
return await self._aio_task
mars/deploy/oscar/session.py:953: in _run_in_background
raise task_result.error.with_traceback(task_result.traceback)
mars/services/task/supervisor/processor.py:369: in run
await self._process_stage_chunk_graph(*stage_args)
mars/services/task/supervisor/processor.py:247: in _process_stage_chunk_graph
chunk_to_result = await self._executor.execute_subtask_graph(
mars/services/task/execution/ray/executor.py:551: in execute_subtask_graph
meta_list = await asyncio.gather(*output_meta_object_refs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
awaitable = ObjectRef(cae5e964086715a4ffffffffffffffffffffffff0100000001000000)
@types.coroutine
def _wrap_awaitable(awaitable):
"""Helper for asyncio.ensure_future().
Wraps awaitable (an object with __await__) into a coroutine
that will later be wrapped in a Task by ensure_future().
"""
> return (yield from awaitable.__await__())
E ray.exceptions.RayTaskError(ValueError): ray::execute_subtask() (pid=20439, ip=127.0.0.1)
E File "/home/admin/Work/mars/mars/services/task/execution/ray/executor.py", line 185, in execute_subtask
E execute(context, chunk.op)
E File "/home/admin/Work/mars/mars/core/operand/core.py", line 491, in execute
E result = executor(results, op)
E File "/home/admin/Work/mars/mars/dataframe/indexing/sample.py", line 439, in execute
E ctx[op.outputs[0].key] = in_data.sample(
E File "/home/admin/.pyenv/versions/3.8.13/lib/python3.8/site-packages/pandas/core/generic.py", line 5444, in sample
E weights = sample.preprocess_weights(self, weights, axis)
E File "/home/admin/.pyenv/versions/3.8.13/lib/python3.8/site-packages/pandas/core/sample.py", line 64, in preprocess_weights
E if lib.has_infs(weights):
E File "pandas/_libs/lib.pyx", line 526, in pandas._libs.lib.has_infs
E File "stringsource", line 660, in View.MemoryView.memoryview_cwrapper
E File "stringsource", line 350, in View.MemoryView.memoryview.__cinit__
E ValueError: buffer source array is read-only
../../.pyenv/versions/3.8.13/lib/python3.8/asyncio/tasks.py:695: RayTaskError(ValueError)
To Reproduce To help us reproducing this bug, please provide information below:
- Your Python version 3.8.13
- The version of Mars you use
- Versions of crucial packages, such as numpy, scipy and pandas pandas==1.4.4
- Full stack of the error.
- Minimized code to reproduce the error.
Expected behavior A clear and concise description of what you expected to happen.
Additional context Add any other context about the problem here.