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

Engineering mode-based setting: %xmode #235

Open
klauer opened this issue Oct 7, 2020 · 0 comments
Open

Engineering mode-based setting: %xmode #235

klauer opened this issue Oct 7, 2020 · 0 comments

Comments

@klauer
Copy link
Contributor

klauer commented Oct 7, 2020

Expected Behavior

  • When in engineering mode, show full tracebacks
  • When in general user mode, show limited tracebacks

Current Behavior

  • Show full tracebacks all the time to everyone

Possible Solution

  • Engineering mode: %xmode verbose
  • User mode: %xmode plain (minimal?)

Context

Related pcdshub/pcdsdevices#591

Example

In [31]: def test(i=0):
    ...:     if i > 5:
    ...:         raise ValueError('this is the exception text')
    ...:     test(i + 1)
    ...:

In [36]: %xmode
Exception reporting mode: Plain

In [37]: test()
Traceback (most recent call last):
  File "<ipython-input-37-fbd55f77ab7c>", line 1, in <module>
    test()
  File "<ipython-input-31-b5ce4b1c52dd>", line 4, in test
    test(i + 1)
  File "<ipython-input-31-b5ce4b1c52dd>", line 4, in test
    test(i + 1)
  File "<ipython-input-31-b5ce4b1c52dd>", line 4, in test
    test(i + 1)
  File "<ipython-input-31-b5ce4b1c52dd>", line 4, in test
    test(i + 1)
  File "<ipython-input-31-b5ce4b1c52dd>", line 4, in test
    test(i + 1)
  File "<ipython-input-31-b5ce4b1c52dd>", line 4, in test
    test(i + 1)
  File "<ipython-input-31-b5ce4b1c52dd>", line 3, in test
    raise ValueError('this is the exception text')
ValueError: this is the exception text


In [38]: %xmode
Exception reporting mode: Context

In [39]: test()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-39-fbd55f77ab7c> in <module>
----> 1 test()

<ipython-input-31-b5ce4b1c52dd> in test(i)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
      5

<ipython-input-31-b5ce4b1c52dd> in test(i)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
      5

<ipython-input-31-b5ce4b1c52dd> in test(i)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
      5

<ipython-input-31-b5ce4b1c52dd> in test(i)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
      5

<ipython-input-31-b5ce4b1c52dd> in test(i)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
      5

<ipython-input-31-b5ce4b1c52dd> in test(i)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
      5

<ipython-input-31-b5ce4b1c52dd> in test(i)
      1 def test(i=0):
      2     if i > 5:
----> 3         raise ValueError('this is the exception text')
      4     test(i + 1)
      5

ValueError: this is the exception text

In [40]: %xmode
Exception reporting mode: Verbose

In [41]: test()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-41-fbd55f77ab7c> in <module>
----> 1 test()
        global test = <function test at 0x7fba28fc9e18>

<ipython-input-31-b5ce4b1c52dd> in test(i=0)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
        global test = <function test at 0x7fba28fc9e18>
        i = 0
      5

<ipython-input-31-b5ce4b1c52dd> in test(i=1)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
        global test = <function test at 0x7fba28fc9e18>
        i = 1
      5

<ipython-input-31-b5ce4b1c52dd> in test(i=2)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
        global test = <function test at 0x7fba28fc9e18>
        i = 2
      5

<ipython-input-31-b5ce4b1c52dd> in test(i=3)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
        global test = <function test at 0x7fba28fc9e18>
        i = 3
      5

<ipython-input-31-b5ce4b1c52dd> in test(i=4)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
        global test = <function test at 0x7fba28fc9e18>
        i = 4
      5

<ipython-input-31-b5ce4b1c52dd> in test(i=5)
      2     if i > 5:
      3         raise ValueError('this is the exception text')
----> 4     test(i + 1)
        global test = <function test at 0x7fba28fc9e18>
        i = 5
      5

<ipython-input-31-b5ce4b1c52dd> in test(i=6)
      1 def test(i=0):
      2     if i > 5:
----> 3         raise ValueError('this is the exception text')
        global ValueError = undefined
      4     test(i + 1)
      5

ValueError: this is the exception text

In [42]: %xmode
Exception reporting mode: Minimal

In [43]: test()
ValueError: this is the exception text
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

No branches or pull requests

1 participant