From 3299182381be300f3ebc33bcfabe5f024e56d400 Mon Sep 17 00:00:00 2001 From: hainaweiben Date: Thu, 9 Jan 2025 16:28:32 +0800 Subject: [PATCH 1/2] Fix deprecation warnings related to dtype and function usage - Replace `find_executable` with `shutil.which` to address deprecation. - Resolve `FutureWarning` by ensuring compatible dtype in Pandas operations. - Explicitly cast values to match column dtype where necessary. --- .../_mars/dataframe/indexing/tests/test_indexing.py | 2 +- .../_mars/dataframe/sort/tests/test_sort_execution.py | 2 ++ python/xorbits/deploy/kubernetes/tests/test_kubernetes.py | 7 +++---- python/xorbits/deploy/slurm/tests/test_slurm.py | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/python/xorbits/_mars/dataframe/indexing/tests/test_indexing.py b/python/xorbits/_mars/dataframe/indexing/tests/test_indexing.py index 6d6e9fc22..2f5ef042b 100644 --- a/python/xorbits/_mars/dataframe/indexing/tests/test_indexing.py +++ b/python/xorbits/_mars/dataframe/indexing/tests/test_indexing.py @@ -679,7 +679,7 @@ def test_loc_use_iloc(): assert isinstance(df2.loc["a3":].op, DataFrameLocGetItem) raw2 = raw.copy() - raw2.index = [f"a{i}" for i in range(3)] + raw2.index = [f"idx{i}" for i in range(3)] df2 = md.DataFrame(raw2, chunk_size=2) assert isinstance(df2.loc[:3].op, DataFrameLocGetItem) diff --git a/python/xorbits/_mars/dataframe/sort/tests/test_sort_execution.py b/python/xorbits/_mars/dataframe/sort/tests/test_sort_execution.py index 0baa91ca4..deb4dc8d9 100644 --- a/python/xorbits/_mars/dataframe/sort/tests/test_sort_execution.py +++ b/python/xorbits/_mars/dataframe/sort/tests/test_sort_execution.py @@ -169,6 +169,7 @@ def test_sort_values_execution(setup, distinct_opt): # test None (issue #1885) df = pd.DataFrame(np.random.rand(1000, 10)) + df[0] = df[0].astype('object') df[0][df[0] < 0.5] = "A" df[0][df[0] != "A"] = None @@ -262,6 +263,7 @@ def test_sort_values_execution(setup, distinct_opt): # test series with None series = pd.Series(np.arange(1000)) + series = series.astype('object') series[series < 500] = "A" series[series != "A"] = None diff --git a/python/xorbits/deploy/kubernetes/tests/test_kubernetes.py b/python/xorbits/deploy/kubernetes/tests/test_kubernetes.py index c93807526..5877c74e4 100644 --- a/python/xorbits/deploy/kubernetes/tests/test_kubernetes.py +++ b/python/xorbits/deploy/kubernetes/tests/test_kubernetes.py @@ -27,7 +27,6 @@ import tempfile import uuid from contextlib import contextmanager -from distutils.spawn import find_executable import numpy as np @@ -45,8 +44,8 @@ k8s = lazy_import("kubernetes") kube_available = ( - find_executable("kubectl") is not None - and find_executable("docker") is not None + shutil.which("kubectl") is not None + and shutil.which("docker") is not None and k8s is not None ) @@ -55,7 +54,7 @@ def _collect_coverage(): dist_coverage_path = os.path.join(XORBITS_ROOT, ".dist-coverage") if os.path.exists(dist_coverage_path): # change ownership of coverage files - if find_executable("sudo"): + if shutil.which("sudo"): proc = subprocess.Popen( [ "sudo", diff --git a/python/xorbits/deploy/slurm/tests/test_slurm.py b/python/xorbits/deploy/slurm/tests/test_slurm.py index 51eb791b9..ba9d70123 100644 --- a/python/xorbits/deploy/slurm/tests/test_slurm.py +++ b/python/xorbits/deploy/slurm/tests/test_slurm.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from distutils.spawn import find_executable +import shutil import pytest @@ -19,7 +19,7 @@ from .... import pandas as pd from .. import SLURMCluster -slurm_available = find_executable("sbatch") is not None +slurm_available = shutil.which("sbatch") is not None def test_header_core_process_memory(): From e310a1b039f27be769fb9b743bf764c3fad5b1e6 Mon Sep 17 00:00:00 2001 From: hainaweiben Date: Thu, 9 Jan 2025 16:49:55 +0800 Subject: [PATCH 2/2] fix blake8 --- .../xorbits/_mars/dataframe/sort/tests/test_sort_execution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/xorbits/_mars/dataframe/sort/tests/test_sort_execution.py b/python/xorbits/_mars/dataframe/sort/tests/test_sort_execution.py index deb4dc8d9..30f4fb193 100644 --- a/python/xorbits/_mars/dataframe/sort/tests/test_sort_execution.py +++ b/python/xorbits/_mars/dataframe/sort/tests/test_sort_execution.py @@ -169,7 +169,7 @@ def test_sort_values_execution(setup, distinct_opt): # test None (issue #1885) df = pd.DataFrame(np.random.rand(1000, 10)) - df[0] = df[0].astype('object') + df[0] = df[0].astype("object") df[0][df[0] < 0.5] = "A" df[0][df[0] != "A"] = None @@ -263,7 +263,7 @@ def test_sort_values_execution(setup, distinct_opt): # test series with None series = pd.Series(np.arange(1000)) - series = series.astype('object') + series = series.astype("object") series[series < 500] = "A" series[series != "A"] = None