Skip to content

Commit

Permalink
filter FuturreWarning's on partition level for unidist
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed Sep 25, 2023
1 parent 997b2ea commit 2322d9b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

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

import warnings

import unidist

from modin.core.dataframe.pandas.partitioning.partition import PandasDataframePartition
Expand Down Expand Up @@ -351,12 +353,16 @@ def _apply_func(partition, func, *args, **kwargs): # pragma: no cover
destructuring it causes a performance penalty.
"""
try:
result = func(partition, *args, **kwargs)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning)
result = func(partition, *args, **kwargs)
# Sometimes Arrow forces us to make a copy of an object before we operate on it. We
# don't want the error to propagate to the user, and we want to avoid copying unless
# we absolutely have to.
except ValueError:
result = func(partition.copy(), *args, **kwargs)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning)
result = func(partition.copy(), *args, **kwargs)
return (
result,
len(result) if hasattr(result, "__len__") else 0,
Expand Down Expand Up @@ -393,12 +399,16 @@ def _apply_list_of_funcs(call_queue, partition): # pragma: no cover
args = deserialize(f_args)
kwargs = deserialize(f_kwargs)
try:
partition = func(partition, *args, **kwargs)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning)
partition = func(partition, *args, **kwargs)
# Sometimes Arrow forces us to make a copy of an object before we operate on it. We
# don't want the error to propagate to the user, and we want to avoid copying unless
# we absolutely have to.
except ValueError:
partition = func(partition.copy(), *args, **kwargs)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning)
partition = func(partition.copy(), *args, **kwargs)

return (
partition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

"""Module houses classes responsible for storing a virtual partition and applying a function to it."""

import warnings

import pandas
import unidist

Expand Down Expand Up @@ -310,7 +312,9 @@ def _deploy_unidist_func(
Unidist functions are not detected by codecov (thus pragma: no cover).
"""
f_args = deserialize(f_args)
result = deployer(axis, f_to_deploy, f_args, f_kwargs, *args, **kwargs)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning)
result = deployer(axis, f_to_deploy, f_args, f_kwargs, *args, **kwargs)
if not extract_metadata:
return result
ip = unidist.get_ip()
Expand Down

0 comments on commit 2322d9b

Please sign in to comment.