From 8a62c3b551a225745a15253a975e77b7a1673d6f Mon Sep 17 00:00:00 2001 From: Anatoly Myachev Date: Wed, 15 May 2024 15:35:03 +0200 Subject: [PATCH] REFACTOR-#7271: Remove `instance_type` attribute of axis partitions (#7268) Signed-off-by: Anatoly Myachev --- modin/core/dataframe/base/partitioning/axis_partition.py | 6 ++---- .../pandas_on_dask/partitioning/virtual_partition.py | 2 -- .../pandas_on_python/partitioning/virtual_partition.py | 3 --- .../cudf_on_ray/partitioning/axis_partition.py | 3 --- .../pandas_on_ray/partitioning/virtual_partition.py | 1 - .../pandas_on_unidist/partitioning/virtual_partition.py | 1 - 6 files changed, 2 insertions(+), 14 deletions(-) diff --git a/modin/core/dataframe/base/partitioning/axis_partition.py b/modin/core/dataframe/base/partitioning/axis_partition.py index e184153d3da..7a55dfc4baa 100644 --- a/modin/core/dataframe/base/partitioning/axis_partition.py +++ b/modin/core/dataframe/base/partitioning/axis_partition.py @@ -14,7 +14,7 @@ """Base class of an axis partition for a Modin Dataframe.""" from abc import ABC, abstractmethod -from typing import Any, Callable, Iterable, Optional, Tuple, Union +from typing import Any, Callable, Iterable, Optional, Tuple, Type, Union from modin.logging import ClassLogger from modin.logging.config import LogLevel @@ -95,8 +95,7 @@ def apply( pass # Child classes must have these in order to correctly subclass. - instance_type = None - partition_type = None + partition_type: Type _PARTITIONS_METADATA_LEN = 0 def _wrap_partitions( @@ -119,7 +118,6 @@ def _wrap_partitions( List of wrapped remote partition objects. """ assert self.partition_type is not None - assert self.instance_type is not None # type: ignore if extract_metadata is None: # If `_PARTITIONS_METADATA_LEN == 0` then the execution doesn't support metadata diff --git a/modin/core/execution/dask/implementations/pandas_on_dask/partitioning/virtual_partition.py b/modin/core/execution/dask/implementations/pandas_on_dask/partitioning/virtual_partition.py index 59c7bb4ccdc..3fc37855d6f 100644 --- a/modin/core/execution/dask/implementations/pandas_on_dask/partitioning/virtual_partition.py +++ b/modin/core/execution/dask/implementations/pandas_on_dask/partitioning/virtual_partition.py @@ -14,7 +14,6 @@ """Module houses classes responsible for storing a virtual partition and applying a function to it.""" import pandas -from distributed import Future from distributed.utils import get_ip from modin.core.dataframe.pandas.partitioning.axis_partition import ( @@ -51,7 +50,6 @@ class PandasOnDaskDataframeVirtualPartition(PandasDataframeAxisPartition): axis = None _PARTITIONS_METADATA_LEN = 3 # (length, width, ip) partition_type = PandasOnDaskDataframePartition - instance_type = Future @property def list_of_ips(self): diff --git a/modin/core/execution/python/implementations/pandas_on_python/partitioning/virtual_partition.py b/modin/core/execution/python/implementations/pandas_on_python/partitioning/virtual_partition.py index 1204151742f..611ff3c8b18 100644 --- a/modin/core/execution/python/implementations/pandas_on_python/partitioning/virtual_partition.py +++ b/modin/core/execution/python/implementations/pandas_on_python/partitioning/virtual_partition.py @@ -13,8 +13,6 @@ """The module defines interface for a virtual partition with pandas storage format and python engine.""" -import pandas - from modin.core.dataframe.pandas.partitioning.axis_partition import ( PandasDataframeAxisPartition, ) @@ -48,7 +46,6 @@ class PandasOnPythonDataframeAxisPartition(PandasDataframeAxisPartition): """ partition_type = PandasOnPythonDataframePartition - instance_type = pandas.DataFrame @_inherit_docstrings(PandasOnPythonDataframeAxisPartition.__init__) diff --git a/modin/core/execution/ray/implementations/cudf_on_ray/partitioning/axis_partition.py b/modin/core/execution/ray/implementations/cudf_on_ray/partitioning/axis_partition.py index b5f284fe46b..a7e03a6b14c 100644 --- a/modin/core/execution/ray/implementations/cudf_on_ray/partitioning/axis_partition.py +++ b/modin/core/execution/ray/implementations/cudf_on_ray/partitioning/axis_partition.py @@ -13,8 +13,6 @@ """Module houses classes of axis partitions implemented using Ray and cuDF.""" -import cudf - from modin.core.execution.ray.common import RayWrapper from .partition import cuDFOnRayDataframePartition @@ -34,7 +32,6 @@ def __init__(self, partitions): self.partitions = [obj for obj in partitions] partition_type = cuDFOnRayDataframePartition - instance_type = cudf.DataFrame class cuDFOnRayDataframeColumnPartition(cuDFOnRayDataframeAxisPartition): diff --git a/modin/core/execution/ray/implementations/pandas_on_ray/partitioning/virtual_partition.py b/modin/core/execution/ray/implementations/pandas_on_ray/partitioning/virtual_partition.py index 62903330ab9..67d21f6cbe0 100644 --- a/modin/core/execution/ray/implementations/pandas_on_ray/partitioning/virtual_partition.py +++ b/modin/core/execution/ray/implementations/pandas_on_ray/partitioning/virtual_partition.py @@ -51,7 +51,6 @@ class PandasOnRayDataframeVirtualPartition(PandasDataframeAxisPartition): _PARTITIONS_METADATA_LEN = 3 # (length, width, ip) partition_type = PandasOnRayDataframePartition - instance_type = ray.ObjectRef axis = None # these variables are intentionally initialized at runtime (see #6023) diff --git a/modin/core/execution/unidist/implementations/pandas_on_unidist/partitioning/virtual_partition.py b/modin/core/execution/unidist/implementations/pandas_on_unidist/partitioning/virtual_partition.py index f4e8f456e5c..dbbbca0d5c9 100644 --- a/modin/core/execution/unidist/implementations/pandas_on_unidist/partitioning/virtual_partition.py +++ b/modin/core/execution/unidist/implementations/pandas_on_unidist/partitioning/virtual_partition.py @@ -52,7 +52,6 @@ class PandasOnUnidistDataframeVirtualPartition(PandasDataframeAxisPartition): _PARTITIONS_METADATA_LEN = 3 # (length, width, ip) partition_type = PandasOnUnidistDataframePartition - instance_type = unidist.core.base.object_ref.ObjectRef axis = None # these variables are intentionally initialized at runtime (see #6023)