Closed lgarrison closed 6 years ago
While I am hesitant to add dependencies, looks like wurlitzer
itself does not have any further dependencies.
Definitely a welcome improvement in terms of usability. Do you mind propagating this to all the wrappers?
Digging a little more, I think there's a better solution (but with some complications). We can use wurlitzer.sys_pipes()
to get the live stderr
stream in the notebook, which is good for progress bars and also works for error messages. So I think the RuntimeError
would just go back to the generic "A runtime error occurred" message, which is probably okay.
But this doesn't work on the command line, because sys_pipes()
can't redirect stderr
to itself. But we can check if stderr is a TTY and redirect based on that. I'll open a PR to try it out.
Whenever the Python C extension throws an error (e.g. due to input validation),
None
gets returned to the Python wrapper. However, we then try to unpack that as a 2-tuple of(extn_results, api_time)
, which results in aTypeError
and the error message'NoneType' object is not iterable
, which isn't helpful to the user.This is less confusing on the command line when the error message from
stderr
is also immediately visible, but it's pretty confusing in a Jupyter notebook since the error message isn't captured and displayed there.Here's an example that demonstrates the issue:
In a Notebook only the following is displayed:
The simple fix is to just check if the returned result is
None
before unpacking. However, I propose we actually try to capture thestderr
error message and display it to the user. One way to do this would be with the wurlitzer package. This section of DD.py would then become:Then you get the real error message, in a Notebook or command line:
@manodeep, what do you think? wurlitzer is on pip for Python 2 and 3.