-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Gracefully handle empty CSV * addressed comments * Add a new test case to verify cloudpickle fix * Allow raising error on empty CSV * ignore_reinit_error=True to avoid init twice * Bump up the version
- Loading branch information
1 parent
9ba2aba
commit 2b213f8
Showing
7 changed files
with
353 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import unittest | ||
from typing import Any | ||
import pyarrow as pa | ||
import ray | ||
|
||
|
||
class CustomObj: | ||
def pickle_len(self, obj: Any): | ||
pass | ||
|
||
|
||
class AnyObject: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def pickle_len(self, obj): | ||
return len(ray.cloudpickle.dumps(obj)) | ||
|
||
|
||
@ray.remote | ||
def calculate_pickled_length(custom_obj: CustomObj): | ||
|
||
table = pa.table({"a": pa.array(list(range(1000000)))}) | ||
|
||
full_len = custom_obj.pickle_len(table) | ||
sliced_len = custom_obj.pickle_len(table[0:1]) | ||
|
||
return [sliced_len, full_len] | ||
|
||
|
||
class TestCloudpickleBugFix(unittest.TestCase): | ||
""" | ||
This test is specifically to validate if nothing has | ||
changed across Ray versions regarding the cloudpickle behavior. | ||
If the tables are sliced, cloudpickle used to dump entire buffer. | ||
However, Ray has added a custom serializer to get around this problem in | ||
https://github.com/ray-project/ray/pull/29993 for the issue at | ||
https://github.com/ray-project/ray/issues/29814. | ||
Note: If this test fails, it indicates that you may need to address the cloudpickle | ||
bug before upgrading ray version. | ||
""" | ||
|
||
def test_sanity(self): | ||
ray.init(local_mode=True, ignore_reinit_error=True) | ||
|
||
result = ray.get(calculate_pickled_length.remote(AnyObject())) | ||
|
||
self.assertTrue(result[0] < 1000) | ||
self.assertTrue(result[1] >= 5000000) |
Empty 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Y 1754-08-30T22:43:41 | ||
"" 2022-08-10T22:43:21 | ||
N 9999-08-10T22:43:21.123456 |
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
Oops, something went wrong.