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

[FEA] Remove Parsing of C++ Exception String #10632

Closed
codereport opened this issue Apr 11, 2022 · 2 comments · Fixed by #12426
Closed

[FEA] Remove Parsing of C++ Exception String #10632

codereport opened this issue Apr 11, 2022 · 2 comments · Fixed by #12426
Assignees
Labels
0 - Backlog In queue waiting for assignment feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API.

Comments

@codereport
Copy link
Contributor

Currently, in certain places in cuDF Python we parse the string messages returned from C++ std::exception::what. This should be removed and replaced by returning a more appropriate exception that Cython can automatically handle. If there is no "appropriate" exception, then a custom exception should be created and the Cython machinery should be written to handle it.

An example of this is the following:

        except RuntimeError as e:
            if "out of bounds" in str(e):
                raise IndexError(
                    f"index out of bounds for column of size {len(self)}"
                ) from e
            raise

where from the C++ code we could throw a std::out_of_range exception which would automatically be promoted to an IndexError.

This is a first step of the initial work detailed in #10200.

@codereport codereport added feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API. labels Apr 11, 2022
@codereport codereport self-assigned this Apr 11, 2022
@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@github-actions
Copy link

github-actions bot commented Aug 9, 2022

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

@shwina shwina added the 0 - Backlog In queue waiting for assignment label Oct 27, 2022
@vyasr vyasr assigned vyasr and unassigned codereport Nov 29, 2022
rapids-bot bot pushed a commit that referenced this issue Feb 25, 2023
This PR identifies places where cuDF Python is parsing exception messages from libcudf in order to throw an appropriate Python exception and modifies the associated libcudf error macros (`CUDF_EXPECTS` or `CUDF_FAIL`) to throw a more descriptive exception. In order to fully support this behavior with arbitrary libcudf exceptions, this PR also introduces a custom Cython exception handler that can be extended to catch and handle any new type of exception thrown by libcudf. To cases where issues with the dtype of an argument is treated as a TypeError rather than a ValueError in pandas, a new exception type `dtype_error : public logic_error` is defined and mapped to a TypeError in Python. This PR does not aim to exhaustively improve the choice of thrown exceptions throughout libcudf, only in places that are immediately relevant to removing message parsing in cudf Python.

Resolves #10632

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Robert (Bobby) Evans (https://github.com/revans2)
  - Ashwin Srinath (https://github.com/shwina)
  - Matthew Roeschke (https://github.com/mroeschke)
  - David Wendt (https://github.com/davidwendt)
  - Nghia Truong (https://github.com/ttnghia)

URL: #12426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - Backlog In queue waiting for assignment feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants