Repository: modin-project/modin
Pull request: FIX-#3741: Added delivery of the data argument to df
Signed-off-by: aleksandr.lozovskii <aleksandr.lozovskii@intel.com>

<!--
Thank you for your contribution!
Please review the contributing docs: https://modin.readthedocs.io/en/latest/CONTRIBUTING.html
if you have questions about contributing.
-->

## What do these changes do?

<!-- Please give a short brief about these changes. -->

- [X] commit message follows format outlined [here](https://modin.readthedocs.io/en/latest/contributing.html)
- [X] passes `flake8 modin/ asv_bench/benchmarks scripts/doc_checker.py`
- [X] passes `black --check modin/ asv_bench/benchmarks scripts/doc_checker.py`
- [X] signed commit with `git commit -s` <!-- you can amend your commit with a signature via `git commit -amend -s` -->
- [X] Resolves [#3741](https://github.com/modin-project/modin/issues/3741)
- [X] tests added and passing
- [X] module layout described at `docs/developer/architecture.rst` is up-to-date 

The problem was that in the `cloud` mode modin was created a proxy `DataFrame`, where the element type was not `float64`, as intended, but a proxy object. To solve this problem for `DataFrame`, we will pass the data parameter from the local side to the remote side.

Problem statement:
IndexError: index 0 is out of bounds for axis 0 with size 0
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Windows 10
- **Modin version** (`modin.__version__`): 0.12.0
- **Python version**: 3.8.11
- **Code we can use to reproduce**:

```
set MODIN_EXPERIMENTAL=1
set MODIN_ENGINE=Python
python -m pytest --capture=no --simulate-cloud=normal modin/pandas/test/dataframe/test_default.py::test_kurt_kurtosis[kurtosis-True-True-over_rows_int]
```

### Describe the problem

Occurs in 165 tests.

- modin/pandas/test/dataframe/test_default.py::test_kurt_kurtosis[kurtosis-True-True-over_rows_int]
- modin/pandas/test/dataframe/test_default.py::test_kurt_kurtosis[kurtosis-True-True-over_rows_str]
- modin/pandas/test/dataframe/test_default.py::test_kurt_kurtosis[kurtosis-True-False-over_rows_int]
- modin/pandas/test/dataframe/test_default.py::test_kurt_kurtosis[kurtosis-True-False-over_rows_str]
- modin/pandas/test/dataframe/test_default.py::test_kurt_kurtosis[kurtosis-True-None-over_rows_int]

And also in 160 tests.

### Source code / logs

```
E           ========= Remote Traceback (1) =========
E           Traceback (most recent call last):
E             File "C:\Users\alozovsk\Anaconda3\envs\modin\lib\site-packages\rpyc\core\protocol.py", line 338, in _dispatch_request
E               res = self._HANDLERS[handler](self, *args)
E             File "C:\Users\alozovsk\Anaconda3\envs\modin\lib\site-packages\rpyc\core\protocol.py", line 630, in _handle_call
E               return obj(*args, **dict(kwargs))
E             File "C:\prog\modin\modin\pandas\base.py", line 1554, in kurt
E               return self._reduce_dimension(
E             File "C:\prog\modin\modin\pandas\dataframe.py", line 2878, in _reduce_dimension
E               return Series(query_compiler=query_compiler)
E             File "C:\prog\modin\modin\pandas\series.py", line 160, in __init__
E               self._query_compiler = query_compiler.columnarize()
E             File "C:\prog\modin\modin\core\storage_formats\pandas\query_compiler.py", line 661, in columnarize
E               return self.transpose()
E             File "C:\prog\modin\modin\core\storage_formats\pandas\query_compiler.py", line 655, in transpose
E               return self.__constructor__(self._modin_frame.transpose())
E             File "C:\prog\modin\modin\core\dataframe\pandas\dataframe\dataframe.py", line 2299, in transpose
E               np.full(len(self.index), find_common_type(self.dtypes.values)),
E             File "C:\prog\modin\modin\core\storage_formats\pandas\parsers.py", line 127, in find_common_type_cat
E               np.sort(np.unique([c for t in types for c in t.categories])[0]),
E           IndexError: index 0 is out of bounds for axis 0 with size 0

C:\Users\alozovsk\Anaconda3\envs\modin\lib\site-packages\rpyc\core\async_.py:102: IndexError
```

Hints from issue discussion:

Commit message: FIX-#3741: Added delivery of the data argument to df

Signed-off-by: aleksandr.lozovskii <aleksandr.lozovskii@intel.com>

Patch to review:
diff --git a/modin/experimental/cloud/rpyc_proxy.py b/modin/experimental/cloud/rpyc_proxy.py
index c9b524138e6..f36a0c8e5a1 100644
--- a/modin/experimental/cloud/rpyc_proxy.py
+++ b/modin/experimental/cloud/rpyc_proxy.py
@@ -427,6 +427,9 @@ class Wrapper(override, origin_cls, metaclass=ProxyMeta):
         __wrapper_remote__ = remote_cls
 
         def __init__(self, *a, __remote_end__=None, **kw):
+            if __remote_end__ is None:
+                if hasattr(self, "_preprocess_init_args"):
+                    a, kw = self._preprocess_init_args(*a, **kw)
             if __remote_end__ is None:
                 __remote_end__ = remote_cls(*a, **kw)
             while True:
@@ -622,6 +625,27 @@ def iteritems(self):
     ObtainingItems = _deliveringWrapper(Series, mixin=ObtainingItems)
 
     class DataFrameOverrides(_prepare_loc_mixin()):
+        @classmethod
+        def _preprocess_init_args(
+            cls,
+            data=None,
+            index=None,
+            columns=None,
+            dtype=None,
+            copy=None,
+            query_compiler=None,
+        ):
+
+            (data,) = conn.deliver((data,), {})[0]
+            return (), dict(
+                data=data,
+                index=index,
+                columns=columns,
+                dtype=dtype,
+                copy=copy,
+                query_compiler=query_compiler,
+            )
+
         @property
         def dtypes(self):
             remote_dtypes = self.__remote_end__.dtypes


Code review comments:
diff_hunk: @@ -427,6 +427,9 @@ class Wrapper(override, origin_cls, metaclass=ProxyMeta):
         __wrapper_remote__ = remote_cls
 
         def __init__(self, *a, __remote_end__=None, **kw):
+            if __remote_end__ is None:
+                if hasattr(self, "_preprocess_init_args"):
+                    a, kw = self._preprocess_init_args(*a, **kw)
             if __remote_end__ is None:
path: modin/experimental/cloud/rpyc_proxy.py
text: @user1:
do this under single `if` statement, not double