Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modin tests #16260

Merged
merged 26 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
92c60be
add modin tests + update license
ckw017 Jun 4, 2021
19d7f37
Use modin commit with necessary patch, drop hacky test
ckw017 Jun 7, 2021
10f509c
Remove some of the complex tests
ckw017 Jun 7, 2021
076452c
update requirements.txt
ckw017 Jun 7, 2021
2adeacb
Bump pandas to cmodin compatible version
ckw017 Jun 7, 2021
3b51334
Drop pandas version
ckw017 Jun 7, 2021
fac1fe7
Check if dropping pandas works
ckw017 Jun 7, 2021
088dc56
Modin needs python>3.7
ckw017 Jun 7, 2021
ff3ac79
Install latest compatible version of modin for python < 3.7
ckw017 Jun 7, 2021
9931014
Use modin 0.8.0 for python < 3.7
ckw017 Jun 7, 2021
dac9e37
Fix comment
ckw017 Jun 7, 2021
5239d92
Add test_modin to medium tests
ckw017 Jun 8, 2021
880a226
Don't import modin until after version check
ckw017 Jun 8, 2021
ce3bcea
Move test_utils import into compatible check
ckw017 Jun 8, 2021
f6fd869
lint
ckw017 Jun 8, 2021
cb6efaf
Move datagen into test_modin
ckw017 Jun 8, 2021
8addfc2
Move client fixture to top
ckw017 Jun 8, 2021
0249e66
test_from_modin doesn't actually work (skipped before because of inco…
ckw017 Jun 8, 2021
a7ccae3
rerun
ckw017 Jun 9, 2021
cd1a6e8
Update LICENSE
ckw017 Jun 9, 2021
a7f56a7
Move modin test to 3.7 job
ckw017 Jun 10, 2021
87df080
restore requirements.txt to original deps
ckw017 Jun 10, 2021
299e018
Add back modin version check (prevent windows from running with outda…
ckw017 Jun 10, 2021
481361b
keep modin requirement in requirements.txt
ckw017 Jun 10, 2021
5e85439
Drop modin from requirements.txt
ckw017 Jun 11, 2021
b17bd4e
rerun
ckw017 Jun 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,22 @@ Code in python/ray/_private/prometheus_exporter.py is adapted from https://githu
# 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.

--------------------------------------------------------------------------------
Code in python/ray/tests/test_modin is adapted from
http://github.com/modin-project/modin/master/modin/pandas/test/test_general.py
and http://github.com/modin-project/modin/master/modin/pandas/test/utils.py

Copyright (c) 2018-2020 Modin Developers.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
1 change: 1 addition & 0 deletions python/ray/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ py_test_module_list(
"test_memory_scheduling.py",
"test_plasma_unlimited.py",
"test_metrics.py",
"test_modin.py",
ckw017 marked this conversation as resolved.
Show resolved Hide resolved
"test_multi_node.py",
"test_multi_node_2.py",
"test_multi_node_3.py",
Expand Down
134 changes: 134 additions & 0 deletions python/ray/tests/modin_test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Licensed to Modin Development Team under one or more contributor license
# agreements. See the NOTICE file distributed with this work for additional
# information regarding copyright ownership. The Modin Development Team
# licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, 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.
#
# This file is copied and adapted from
# http://github.com/modin-project/modin/master/modin/pandas/test/utils.py

import pandas
import modin.pandas as pd
from modin.utils import to_pandas
from pandas.testing import (assert_series_equal, assert_frame_equal,
assert_extension_array_equal, assert_index_equal)
import numpy as np


def categories_equals(left, right):
assert (left.ordered and right.ordered) or (not left.ordered
and not right.ordered)
assert_extension_array_equal(left, right)


def df_categories_equals(df1, df2):
if not hasattr(df1, "select_dtypes"):
if isinstance(df1, pandas.CategoricalDtype):
return categories_equals(df1, df2)
elif isinstance(getattr(df1, "dtype"),
pandas.CategoricalDtype) and isinstance(
getattr(df1, "dtype"), pandas.CategoricalDtype):
return categories_equals(df1.dtype, df2.dtype)
else:
return True

categories_columns = df1.select_dtypes(include="category").columns
for column in categories_columns:
assert_extension_array_equal(
df1[column].values,
df2[column].values,
check_dtype=False,
)


def df_equals(df1, df2):
"""Tests if df1 and df2 are equal.

Args:
df1: (pandas or modin DataFrame or series) dataframe to test if equal.
df2: (pandas or modin DataFrame or series) dataframe to test if equal.

Returns:
True if df1 is equal to df2.
"""
# Gets AttributError if modin's groupby object is not import like this
from modin.pandas.groupby import DataFrameGroupBy

groupby_types = (pandas.core.groupby.DataFrameGroupBy, DataFrameGroupBy)

# The typing behavior of how pandas treats its index is not consistent when
# the length of the DataFrame or Series is 0, so we just verify that the
# contents are the same.
if (hasattr(df1, "index") and hasattr(df2, "index") and len(df1) == 0
and len(df2) == 0):
if type(df1).__name__ == type(df2).__name__:
if hasattr(df1, "name") and hasattr(
df2, "name") and df1.name == df2.name:
return
if (hasattr(df1, "columns") and hasattr(df2, "columns")
and df1.columns.equals(df2.columns)):
return
assert False

if isinstance(df1, (list, tuple)) and all(
isinstance(d, (pd.DataFrame, pd.Series, pandas.DataFrame,
pandas.Series)) for d in df1):
assert isinstance(df2, type(df1)), "Different type of collection"
assert len(df1) == len(df2), "Different length result"
return (df_equals(d1, d2) for d1, d2 in zip(df1, df2))

# Convert to pandas
if isinstance(df1, (pd.DataFrame, pd.Series)):
df1 = to_pandas(df1)
if isinstance(df2, (pd.DataFrame, pd.Series)):
df2 = to_pandas(df2)

if isinstance(df1, pandas.DataFrame) and isinstance(df2, pandas.DataFrame):
if (df1.empty and not df2.empty) or (df2.empty and not df1.empty):
assert False, "One of the passed frames is empty, when other isn't"
elif df1.empty and df2.empty and type(df1) != type(df2):
assert (
False
), f"Empty frames have different types: {type(df1)} != {type(df2)}"

if isinstance(df1, pandas.DataFrame) and isinstance(df2, pandas.DataFrame):
assert_frame_equal(
df1,
df2,
check_dtype=False,
check_datetimelike_compat=True,
check_index_type=False,
check_column_type=False,
check_categorical=False,
)
df_categories_equals(df1, df2)
elif isinstance(df1, pandas.Index) and isinstance(df2, pandas.Index):
assert_index_equal(df1, df2)
elif isinstance(df1, pandas.Series) and isinstance(df2, pandas.Series):
assert_series_equal(
df1, df2, check_dtype=False, check_series_type=False)
elif isinstance(df1, groupby_types) and isinstance(df2, groupby_types):
for g1, g2 in zip(df1, df2):
assert g1[0] == g2[0]
df_equals(g1[1], g2[1])
elif (isinstance(df1, pandas.Series) and isinstance(df2, pandas.Series)
and df1.empty and df2.empty):
assert all(df1.index == df2.index)
assert df1.dtypes == df2.dtypes
elif isinstance(df1, pandas.core.arrays.numpy_.PandasArray):
assert isinstance(df2, pandas.core.arrays.numpy_.PandasArray)
assert df1 == df2
elif isinstance(df1, np.recarray) and isinstance(df2, np.recarray):
np.testing.assert_array_equal(df1, df2)
else:
if df1 != df2:
np.testing.assert_almost_equal(df1, df2)
2 changes: 2 additions & 0 deletions python/ray/tests/test_mldataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def test_union(ray_start_regular_shared):
assert ds.batch_size == 0


@pytest.mark.skipif(
ckw017 marked this conversation as resolved.
Show resolved Hide resolved
True, reason="Broken on all platforms (incorrect use of gather_sync())")
def test_from_modin(ray_start_regular_shared):
try:
import modin.pandas as pd
Expand Down
Loading