Repository: modin-project/modin

Issue:
REFACTOR: remove redefinition of `_row_lengths` and `_column_widths` functions in `PandasOnDaskDataframe`.
Basic implementation should work for `Dask` engine. It already works for `Ray` engine.

Links to basic implementations: https://github.com/modin-project/modin/blob/d590de080dddb7ed715a58d57c602d96322c4dcf/modin/core/dataframe/pandas/dataframe/dataframe.py#L105
https://github.com/modin-project/modin/blob/d590de080dddb7ed715a58d57c602d96322c4dcf/modin/core/dataframe/pandas/dataframe/dataframe.py#L124

Links to `Dask` redefinitions:
https://github.com/modin-project/modin/blob/d590de080dddb7ed715a58d57c602d96322c4dcf/modin/core/execution/dask/implementations/pandas_on_dask/dataframe/dataframe.py#L47
https://github.com/modin-project/modin/blob/d590de080dddb7ed715a58d57c602d96322c4dcf/modin/core/execution/dask/implementations/pandas_on_dask/dataframe/dataframe.py#L64



Discussion:

Resolving patch:
diff --git a/modin/core/execution/dask/implementations/pandas_on_dask/dataframe/dataframe.py b/modin/core/execution/dask/implementations/pandas_on_dask/dataframe/dataframe.py
--- a/modin/core/execution/dask/implementations/pandas_on_dask/dataframe/dataframe.py
+++ b/modin/core/execution/dask/implementations/pandas_on_dask/dataframe/dataframe.py
@@ -15,7 +15,6 @@
 
 from modin.core.dataframe.pandas.dataframe.dataframe import PandasDataframe
 from ..partitioning.partition_manager import PandasOnDaskDataframePartitionManager
-from modin.core.execution.dask.common.engine_wrapper import DaskWrapper
 
 
 class PandasOnDaskDataframe(PandasDataframe):
@@ -41,86 +40,3 @@ class PandasOnDaskDataframe(PandasDataframe):
     """
 
     _partition_mgr_cls = PandasOnDaskDataframePartitionManager
-
-    def _get_partition_size_along_axis(self, partition, axis=0):
-        """
-        Compute the length along the specified axis of the specified partition.
-
-        Parameters
-        ----------
-        partition : ``PandasOnDaskDataframeVirtualPartition`` or ``PandasOnDaskDataframePartition``
-            The partition whose size to compute.
-        axis : int, default: 0
-            The axis along which to compute size.
-
-        Returns
-        -------
-        list
-            A list of lengths along the specified axis that sum to the overall length of the partition
-            along the specified axis.
-
-        Notes
-        -----
-        This utility function is used to ensure that computation occurs asynchronously across all partitions
-        whether the partitions are virtual or physical partitions.
-        """
-        if isinstance(partition, self._partition_mgr_cls._partition_class):
-            return [
-                partition.apply(
-                    lambda df: len(df) if not axis else len(df.columns)
-                ).list_of_blocks[0]
-            ]
-        elif partition.axis == axis:
-            return [
-                ptn.apply(
-                    lambda df: len(df) if not axis else len(df.columns)
-                ).list_of_blocks[0]
-                for ptn in partition.list_of_block_partitions
-            ]
-        return [
-            partition.list_of_block_partitions[0]
-            .apply(lambda df: len(df) if not axis else (len(df.columns)))
-            .list_of_blocks[0]
-        ]
-
-    @property
-    def _row_lengths(self):
-        """
-        Compute ther row partitions lengths if they are not cached.
-
-        Returns
-        -------
-        list
-            A list of row partitions lengths.
-        """
-        if self._row_lengths_cache is None:
-            row_lengths_list = DaskWrapper.materialize(
-                [
-                    self._get_partition_size_along_axis(obj, axis=0)
-                    for obj in self._partitions.T[0]
-                ]
-            )
-            self._row_lengths_cache = [sum(len_list) for len_list in row_lengths_list]
-        return self._row_lengths_cache
-
-    @property
-    def _column_widths(self):
-        """
-        Compute the column partitions widths if they are not cached.
-
-        Returns
-        -------
-        list
-            A list of column partitions widths.
-        """
-        if self._column_widths_cache is None:
-            col_widths_list = DaskWrapper.materialize(
-                [
-                    self._get_partition_size_along_axis(obj, axis=1)
-                    for obj in self._partitions[0]
-                ]
-            )
-            self._column_widths_cache = [
-                sum(width_list) for width_list in col_widths_list
-            ]
-        return self._column_widths_cache


Test patch: