-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
84 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
import ray | ||
import raydp | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def spark_on_ray_small(request): | ||
ray.init(num_cpus=2, include_dashboard=False) | ||
spark = raydp.init_spark("test", 1, 1, "500 M") | ||
|
||
def stop_all(): | ||
raydp.stop_spark() | ||
ray.shutdown() | ||
|
||
request.addfinalizer(stop_all) | ||
return spark | ||
|
||
|
||
def test_raydp_roundtrip(spark_on_ray_small): | ||
spark = spark_on_ray_small | ||
spark_df = spark.createDataFrame([(1, "a"), (2, "b"), (3, "c")], | ||
["one", "two"]) | ||
rows = [(r.one, r.two) for r in spark_df.take(3)] | ||
ds = ray.data.from_spark(spark_df) | ||
values = [(r["one"], r["two"]) for r in ds.take(6)] | ||
assert values == rows | ||
df = ds.to_spark(spark) | ||
rows_2 = [(r.one, r.two) for r in df.take(3)] | ||
assert values == rows_2 | ||
|
||
|
||
def test_raydp_to_spark(spark_on_ray_small): | ||
spark = spark_on_ray_small | ||
n = 5 | ||
ds = ray.data.range_arrow(n) | ||
values = [r["value"] for r in ds.take(5)] | ||
df = ds.to_spark(spark) | ||
rows = [r.value for r in df.take(5)] | ||
assert values == rows | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
sys.exit(pytest.main(["-v", __file__])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ s3fs | |
modin>=0.8.3; python_version < '3.7' | ||
modin>=0.10.0; python_version >= '3.7' | ||
pytest-repeat | ||
raydp-nightly |