-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Data] Support PyArrow 14.0.1 #41036
Conversation
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
if: build.env("BUILDKITE_PIPELINE_ID") == "0189e759-8c96-4302-b6b5-b4274406bf89" | ||
# TODO(bveeramani): remove soft_fail when nightly tests are stable | ||
soft_fail: true | ||
# if: build.env("BUILDKITE_PIPELINE_ID") == "0189e759-8c96-4302-b6b5-b4274406bf89" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will uncomment this after CI passes
Closing for now. Team can pick up when we decide to prioritize #41139 |
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
To test that Arrow nightly test pass, #41036 temporarily moved the Arrow nightly tests to pre-merge (see this comment). But, we forgot to revert the change before merging the PR. This PR moves the Arrow nightly tests back to post-merge. --------- Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
elif parse_version(pyarrow_version) >= parse_version("14.0.1"): | ||
pa.PyExtensionType.set_auto_load(True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you are not aware, this is making PyArrow vulnerable to https://www.cve.org/CVERecord?id=CVE-2023-47248
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that you want to keep it working to read files created by older versions of Ray (because you know those extension types are safe), but the problem with this general enabling of PyExtensionType is that just having ray imported opens the security hole for your users also when reading other files.
A possible alternative would be to register a PyExtensionType class that uses a custom unpickler that only allows to unpickle your own type, and raises an error for anything else.
A custom unpickler could look like:
import io
import pickle
class RestrictedUnpickler(pickle.Unpickler):
def find_class(self, module, name):
if (module, name) == ("ray.air.util.tensor_extensions.arrow", "ArrowTensorType"):
from ray.air.util.tensor_extensions.arrow import ArrowTensorType
return ArrowTensorType
elif (module, name) == ("pyarrow.lib", "type_for_alias"):
from pyarrow import type_for_alias
return type_for_alias
else:
raise pickle.UnpicklingError("loading '%s.%s' is forbidden" % (module, name))
RestrictedUnpickler(io.BytesIO(serialized)).load()
That was my quick attempt for ArrowTensorType
based on limited knowledge of the code base; it might be too restrictive in general (I don't know which pyarrow data types are allowed). But it should be possible to create something like this that works for all your extension types while still restricting any random pickled data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorisvandenbossche thanks for the guidance. How would we make PyArrow use the custom unpickler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can monkeypatch PyArrow just like the hotfix does:
https://github.com/pitrou/pyarrow-hotfix/blob/69b94597e6f96707b7a7782468fac0920b1ad74a/src/pyarrow_hotfix/__init__.py#L64-L68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pitrou and then we'd use the custom unpickler in __arrow_ext_deserialize__
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha! Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also take a look at pyarrow's own implementation of PyExtensionType (https://github.com/apache/arrow/blob/43f4c286fef92b709853eefef207a50aefd9f5d3/python/pyarrow/types.pxi#L1700-L1742), and then re-register your own version like the pyarrow-hotfix does.
Arrow nightly tests are failing because our custom tensor extension uses pyarrow.PyExtensionType, and apache/arrow#38608 deprecated pyarrow.PyExtensionType in favor of pyarrow.ExtensionType. This PR updates our tensor extension to use the now-recommended APIs. --------- Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
To test that Arrow nightly test pass, ray-project#41036 temporarily moved the Arrow nightly tests to pre-merge (see this comment). But, we forgot to revert the change before merging the PR. This PR moves the Arrow nightly tests back to post-merge. --------- Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Why are these changes needed?
Arrow nightly tests are failing because our custom tensor extension uses
pyarrow.PyExtensionType
, and apache/arrow#38608 deprecatedpyarrow.PyExtensionType
in favor ofpyarrow.ExtensionType
. This PR updates our tensor extension to use the now-recommended APIs.https://buildkite.com/ray-project/postmerge/builds/1593#018baae8-726d-451c-b4e4-db9e95113b81
Related issue number
Fixes #41139
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.