-
Notifications
You must be signed in to change notification settings - Fork 926
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 public APIs to Access Underlying cudf
and pandas
Objects from cudf.pandas
Proxy Objects
#17629
Changes from all commits
b5eea1f
7bc76e5
3cdfe94
34375dc
31f9e99
72ba73f
3fd679f
37764c2
bbe0fa4
cf6888f
528c189
6b744f4
9ec0215
a3c49fd
3f06e70
95ba799
a2e97f5
b96f8ff
0044d8f
a77fecc
aafbd31
f15d37b
f94253d
daaa5df
eaa23cb
9c58a71
69837f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES. | ||
# All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import abc | ||
|
@@ -35,7 +35,9 @@ | |
_fast_slow_function_call, | ||
_FastSlowAttribute, | ||
_FunctionProxy, | ||
_maybe_wrap_result, | ||
_Unusable, | ||
is_proxy_object, | ||
make_final_proxy_type as _make_final_proxy_type, | ||
make_intermediate_proxy_type as _make_intermediate_proxy_type, | ||
register_proxy_func, | ||
|
@@ -266,6 +268,12 @@ def custom_repr_html(obj): | |
html_formatter.for_type(DataFrame, custom_repr_html) | ||
|
||
|
||
def _Series_dtype(self): | ||
# Fast-path to extract dtype from the current | ||
# object without round-tripping through the slow<->fast | ||
return _maybe_wrap_result(self._fsproxy_wrapped.dtype, None) | ||
|
||
|
||
Series = make_final_proxy_type( | ||
"Series", | ||
cudf.Series, | ||
|
@@ -285,6 +293,7 @@ def custom_repr_html(obj): | |
"_constructor": _FastSlowAttribute("_constructor"), | ||
"_constructor_expanddim": _FastSlowAttribute("_constructor_expanddim"), | ||
"_accessors": set(), | ||
"dtype": _Series_dtype, | ||
}, | ||
) | ||
|
||
|
@@ -1704,6 +1713,10 @@ def holiday_calendar_factory_wrapper(*args, **kwargs): | |
) | ||
|
||
|
||
def isinstance_cudf_pandas(obj, type): | ||
return is_proxy_object(obj) and obj.__class__.__name__ == type.__name__ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need API docs for public APIs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I add that in a followup PR to save some CI time? I'd like to get this PR in and fix cuml ASAP. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine. Please file an issue or draft PR to ensure this isn't lost. |
||
|
||
|
||
# timestamps and timedeltas are not proxied, but non-proxied | ||
# pandas types are currently not picklable. Thus, we define | ||
# custom reducer/unpicker functions for these types: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES. | ||
# All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
@@ -204,6 +204,12 @@ def _fsproxy_fast_to_slow(self): | |
return fast_to_slow(self._fsproxy_wrapped) | ||
return self._fsproxy_wrapped | ||
|
||
def as_gpu_object(self): | ||
return self._fsproxy_slow_to_fast() | ||
|
||
Comment on lines
+207
to
+208
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to call |
||
def as_cpu_object(self): | ||
return self._fsproxy_fast_to_slow() | ||
|
||
@property # type: ignore | ||
def _fsproxy_state(self) -> _State: | ||
return ( | ||
|
@@ -221,6 +227,8 @@ def _fsproxy_state(self) -> _State: | |
"_fsproxy_slow_type": slow_type, | ||
"_fsproxy_slow_to_fast": _fsproxy_slow_to_fast, | ||
"_fsproxy_fast_to_slow": _fsproxy_fast_to_slow, | ||
"as_gpu_object": as_gpu_object, | ||
"as_cpu_object": as_cpu_object, | ||
"_fsproxy_state": _fsproxy_state, | ||
} | ||
|
||
|
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.
We should document if this is doing to work with
cudf.Series
if cudf is directly imported. It's fine if the answer is no, or if the answer is UB and we don't promise anything, we should just mention it either way.