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

Plot error message #441

Merged
merged 2 commits into from
May 5, 2023
Merged

Plot error message #441

merged 2 commits into from
May 5, 2023

Conversation

neelasha23
Copy link

@neelasha23 neelasha23 commented Apr 24, 2023

Describe your changes

Better error messages when function used in plotting API is unavailable in the driver.

Issue number

Closes #159

Checklist before requesting a review


📚 Documentation preview 📚: https://jupysql--441.org.readthedocs.build/en/441/


@neelasha23 neelasha23 marked this pull request as draft April 24, 2023 12:27
@neelasha23
Copy link
Author

neelasha23 commented Apr 25, 2023

This is ready for review. Some notes:

  1. Added error message for percentile_disc function. Other functions used in plotting API are: avg, count, max, min, floor. As per documentation these seem to be supported in other drivers.
  2. Currently there are two plots: boxplot and histograms and both are documented in tutorials.
  3. Telemetry call already added to these functions.
  4. i have tried modify_exception but it results in very long messages like :
[Error message]
Ensure that percentile_disc function is available on driver.
<Long stack trace>..
...
..
If you need help solving this issue, send us a message: https://ploomber.io/community
....

So directly used the COMMUNITY link along with the error message.

@idomic @edublancas

@neelasha23 neelasha23 marked this pull request as ready for review April 25, 2023 09:40
@idomic
Copy link

idomic commented Apr 25, 2023

For 4:

i have tried modify_exception but it results in very long messages like :
So directly used the COMMUNITY link along with the error message.

Take a look in the core repo, there's the tag we've added, it'll help you and you won't need to deal with the community link manually.

@neelasha23
Copy link
Author

Take a look in the core repo, there's the tag we've added, it'll help you and you won't need to deal with the community link manually.

Yeah I tried that out like:

except Exception as e:
        e.modify_exception = True
        raise

But the issue with that is , first it prints the msg Ensure that percentile_disc function is available on driver.. then there's a long error stack trace at the end of which If you need help solving this issue, send us a message: https://ploomber.io/community is displayed. Users may overlook this amidst the long msgs. printing the community link manually is ensuring a cleaner display like :

Original error msg 

Ensure that percentile_disc function is available on driver.`

If you need help solving this issue, send us a message: https://ploomber.io/community

<original stack trace>

@idomic

@idomic idomic mentioned this pull request Apr 25, 2023
4 tasks
@neelasha23 neelasha23 force-pushed the plot_err branch 4 times, most recently from 42e0315 to f2b2cbb Compare April 26, 2023 09:55
@neelasha23
Copy link
Author

Modified to raise UsageError
@idomic

@idomic
Copy link

idomic commented Apr 26, 2023

Modified to raise UsageError

I think it makes more sense to use a PlotError, create it if doesn't exist.

@edublancas
Copy link

I think it makes more sense to use a PlotError, create it if doesn't exist.

We can use the existing RuntimeError. I don't think we should be that specific to create a PlotError.

And UsageError isn't the appropriate one here since that should only be used when the user input is the problem. Here the problem is the database (example: doesn't implement the percentile_disc function)

@neelasha23 neelasha23 marked this pull request as draft April 26, 2023 18:48
@neelasha23 neelasha23 marked this pull request as ready for review April 26, 2023 19:12
@neelasha23
Copy link
Author

Changed UsageError to RuntimeError.
@idomic

@neelasha23 neelasha23 requested a review from idomic April 26, 2023 19:13
@neelasha23 neelasha23 force-pushed the plot_err branch 3 times, most recently from 589f5de to bd0a510 Compare April 28, 2023 11:31
Copy link

@yafimvo yafimvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some notes
@neelasha23

CHANGELOG.md Outdated Show resolved Hide resolved
src/sql/plot.py Outdated Show resolved Hide resolved
src/sql/plot.py Outdated Show resolved Hide resolved
assert (
"If you need help solving this issue, "
"send us a message: https://ploomber.io/community" in str(out.error_in_exec)
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should add a successful test where we use percentile_disc without getting this error?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the success testcase:

def test_sqlplot_boxplot(ip_with_dynamic_db, cell, request, test_table_name_dict):

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought maybe we can create a scoped test to make sure that _summary_stats runs fluently with percentile_disc since test_sqlplot_boxplot may fail for other reasons. I guess we can skip it.

@idomic what do you think?
if not, we can merge it from my side.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neelasha23 I tend to agree with Yafim, this test should be isolated. Let’s create a clean one just for the success case of _summary_stats.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added unit cases for _summary_stats

@neelasha23 neelasha23 force-pushed the plot_err branch 4 times, most recently from 25f713d to 4eb2d73 Compare May 4, 2023 06:52
@neelasha23 neelasha23 requested a review from yafimvo May 4, 2023 07:07
Copy link

@yafimvo yafimvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

I added one question before we merge it.

@neelasha23 neelasha23 force-pushed the plot_err branch 4 times, most recently from 8dacd02 to 76c83fe Compare May 5, 2023 11:30
neelasha23 added 2 commits May 5, 2023 18:21
testcase

Fix

Fix

Fix

test fix

test fix

test fix

changelog

usageexception

test

test

error

error

error

error

error

changed to runtimeerror

quest db test

Revert test

Revert test

exception type test

Review comments

changelog

rebase

changelog

Review comments

changed to sqlite

change sequence

lint

revert

added tmp_empty

failure case
@idomic
Copy link

idomic commented May 5, 2023

lgtm.

@idomic idomic merged commit 8ce3334 into ploomber:master May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clearer errors when missing functions
4 participants