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

Custom tracebacks #2223

Merged
merged 5 commits into from
Jul 31, 2012
Merged

Custom tracebacks #2223

merged 5 commits into from
Jul 31, 2012

Conversation

takluyver
Copy link
Member

Rather than special casing IPython.parallel errors (which led to issue #2221), this adds a simple API where exception classes can offer a custom traceback, by defining a _render_traceback_(self) method.

It also adds some documentation on how third parties can integrate packages with IPython. 'Configuration & customisation' seemed the most natural home for this.

We should remember to close #2221 when we merge this - I forgot to put it in a commit message.

"""render traceback to a list of lines"""
return (self.traceback or "No traceback available").splitlines()

# Previous name retained for backwards compatibility.
render_traceback = _render_traceback_
Copy link
Member

Choose a reason for hiding this comment

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

I would reverse this alias, because render_traceback is a real public API (not deprecated), and _render_traceback_ is the custom IPython-specific semi-private API.

I know there's no real difference, but I think this way gives the wrong idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I've done that.

@minrk
Copy link
Member

minrk commented Jul 30, 2012

I know it's technically adding a new API, but it seems like we should include this in 0.13.1 to avoid the inappropriate imports. Do you agree?

@takluyver
Copy link
Member Author

Once we're confident it works, I think the flaw is significant enough to warrant backporting the fix, yes.

@minrk
Copy link
Member

minrk commented Jul 30, 2012

Do we want to add a test to catch this sort of thing in the future?

i.e. start a fresh subprocess IPython, and verify that 'numpy' and
'IPython.parallel/zmq' are not in sys.modules?

I don't remember what the state of our subprocess tests is.

@takluyver
Copy link
Member Author

A subprocess test turned out to be pretty easy. I'm running test_pr now.

@minrk
Copy link
Member

minrk commented Jul 30, 2012

Test results for commit 464d50a merged into master
Platform: darwin

  • python2.6: OK (libraries not available: cython matplotlib oct2py pygments pymongo qt rpy2 tornado wx wx.aui)
  • python2.7: OK (libraries not available: oct2py rpy2 wx wx.aui)
  • python3.2: OK (libraries not available: cython matplotlib oct2py pygments pymongo qt rpy2 wx wx.aui)

Not available for testing:

@minrk
Copy link
Member

minrk commented Jul 30, 2012

Great, then I think it should be good to go.

@takluyver
Copy link
Member Author

I'll leave it overnight (my time) in case anyone else wants to look at it, then I'll merge tomorrow. Thanks for the review.


Both the notebook and the Qt console can display ``svg``, ``png`` and ``jpeg``
representations. The notebook can also display ``html``, ``javascript``,
``json`` and ``latex``. If the methods don't exist, or return ``None``, it falls
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, is there any example of something using display_json?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, and it seems it doesn't actually work in the notebook. I'll take it out of the list.

Copy link
Member

Choose a reason for hiding this comment

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

we do have a display_json in IPython.display do we want to write a warning that not many frontend support it ?

@takluyver
Copy link
Member Author

I've updated the docs.

@Carreau
Copy link
Member

Carreau commented Jul 31, 2012

I'm ok with merging this.

About json, what is/was the use of it ?

@takluyver
Copy link
Member Author

OK, I'll merge this now. Thanks.

I'm not sure about displaying json, but I think maybe it's the future tense we need - what will be the use of it?

takluyver added a commit that referenced this pull request Jul 31, 2012
@takluyver takluyver merged commit 06c27d8 into ipython:master Jul 31, 2012
@Carreau
Copy link
Member

Carreau commented Jul 31, 2012

hum... to exchange data with widget, maybe, but then i wouldn't call it display_ ...
we'll see.

@minrk
Copy link
Member

minrk commented Jul 31, 2012

Pretty much every js widget I have written uses display_json.

minrk added a commit that referenced this pull request Aug 4, 2012
Rather than special casing IPython.parallel errors (which led to issue #2221), this adds a simple API where exception classes can offer a custom traceback, by defining a `_render_traceback_(self)` method.

It also adds some documentation on how third parties can integrate packages with IPython. 'Configuration & customisation' seemed the most natural home for this.

We should remember to close #2221 when we merge this - I forgot to put it in a commit message.
minrk added a commit that referenced this pull request Sep 1, 2012
Rather than special casing IPython.parallel errors (which led to issue #2221), this adds a simple API where exception classes can offer a custom traceback, by defining a `_render_traceback_(self)` method.

It also adds some documentation on how third parties can integrate packages with IPython. 'Configuration & customisation' seemed the most natural home for this.

We should remember to close #2221 when we merge this - I forgot to put it in a commit message.
yarikoptic added a commit to yarikoptic/ipython that referenced this pull request May 2, 2014
* commit 'rel-0.13-33-gcfc5692': (33 commits)
  Backport PR ipython#2347: adjust division error message checking to account for Python 3
  Backport PR ipython#2305: RemoteError._render_traceback_ calls self.render_traceback
  Backport PR ipython#2280: fix SSH passwordless check for OpenSSH
  Backport PR ipython#2270: SSHLauncher tweaks
  Backport PR ipython#2261: Fix: longest_substr([]) -> ''
  Backport PR ipython#2250: fix html in notebook example
  Backport PR ipython#2235: remove spurious print statement from setupbase.py
  fixup
  Backport PR ipython#2223: Custom tracebacks
  Backport PR ipython#2214: use KernelApp.exec_lines/files in IPEngineApp
  Backport PR ipython#2212: catch errors in markdown javascript
  Backport PR ipython#2194: clean nan/inf in json_clean
  Backport PR ipython#2177: remove numpy install from travis/tox scripts
  Backport PR ipython#2169: ipdb: pdef, pdoc, pinfo magics all broken
  Backport PR ipython#2186: removed references to h5py dependence in octave magic documentation
  Backport PR ipython#2185: added test for %store, fixed storemagic
  Backport PR ipython#2170: Fix tab completion with IPython.embed_kernel().
  Backport PR ipython#2163: fix 'remote_profie_dir' typo in SSH launchers
  Backport PR ipython#2117: use explicit url in notebook example
  Backport PR ipython#2126: ipcluster broken with any batch (PBS/LSF/SGE)
  ...
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid importing from IPython.parallel in core
3 participants