Skip to content

Commit

Permalink
return None from lambda to speedup 'ip' computation
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed Oct 16, 2023
1 parent e42e625 commit d1a23f9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

"""Module houses class that wraps data (block partition) and its metadata."""

import pandas
from distributed import Future
from distributed.utils import get_ip

Expand Down Expand Up @@ -307,7 +306,7 @@ def ip(self, materialize=True):
IP address of the node that holds the data.
"""
if self._ip_cache is None:
self._ip_cache = self.apply(lambda df: pandas.DataFrame([]))._ip_cache
self._ip_cache = self.apply(lambda df: None)._ip_cache

Check warning on line 309 in modin/core/execution/dask/implementations/pandas_on_dask/partitioning/partition.py

View check run for this annotation

Codecov / codecov/patch

modin/core/execution/dask/implementations/pandas_on_dask/partitioning/partition.py#L309

Added line #L309 was not covered by tests
if materialize and isinstance(self._ip_cache, Future):
self._ip_cache = DaskWrapper.materialize(self._ip_cache)
return self._ip_cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

"""Module houses class that wraps data (block partition) and its metadata."""

import pandas
import ray
from ray.util import get_node_ip_address

Expand Down Expand Up @@ -331,7 +330,7 @@ def ip(self, materialize=True):
if len(self.call_queue):
self.drain_call_queue()
else:
self._ip_cache = self.apply(lambda df: pandas.DataFrame([]))._ip_cache
self._ip_cache = self.apply(lambda df: None)._ip_cache

Check warning on line 333 in modin/core/execution/ray/implementations/pandas_on_ray/partitioning/partition.py

View check run for this annotation

Codecov / codecov/patch

modin/core/execution/ray/implementations/pandas_on_ray/partitioning/partition.py#L333

Added line #L333 was not covered by tests
if materialize and isinstance(self._ip_cache, ObjectIDType):
self._ip_cache = RayWrapper.materialize(self._ip_cache)
return self._ip_cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import warnings

import pandas
import unidist

from modin.core.dataframe.pandas.partitioning.partition import PandasDataframePartition
Expand Down Expand Up @@ -302,7 +301,7 @@ def ip(self, materialize=True):
if len(self.call_queue):
self.drain_call_queue()
else:
self._ip_cache = self.apply(lambda df: pandas.DataFrame([]))._ip_cache
self._ip_cache = self.apply(lambda df: None)._ip_cache

Check warning on line 304 in modin/core/execution/unidist/implementations/pandas_on_unidist/partitioning/partition.py

View check run for this annotation

Codecov / codecov/patch

modin/core/execution/unidist/implementations/pandas_on_unidist/partitioning/partition.py#L304

Added line #L304 was not covered by tests
if materialize and unidist.is_object_ref(self._ip_cache):
self._ip_cache = UnidistWrapper.materialize(self._ip_cache)
return self._ip_cache
Expand Down

0 comments on commit d1a23f9

Please sign in to comment.