pcdshub / pcdshub/hutch-python
Engineering mode-based setting: %xmode
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1
- Forks
- 18
- Avg merge
- 7d 9h
- Merged PRs (30d)
- 1
Description
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 https://github.com/pcdshub/pcdsdevices/issues/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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the interactive IPython session launcher and configuration reader described for hutch-python, and locate where exception reporting is initialized. Compare the %xmode modes shown in the issue with engineering and general-user behavior. Done means engineering sessions show full tracebacks while general-user sessions show limited tracebacks, with coverage for both modes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100