File indexing completed on 2026-04-09 07:48:47
0001
0002 """
0003 debug.py
0004 ==========
0005
0006 Unfortunately attempting::
0007
0008 from opticks.ana.debug import MyPdb
0009
0010 Gives "Name error cannot import", so have to duplicate the
0011 below piece of code wherever wish to plant breakpoints for
0012 consumption by Pdb.
0013
0014 For a useful interactive stack dump presentation
0015 at "set_trace" breakpoints or errors use ip::
0016
0017 ip(){
0018 local py=${1:-dummy.py};
0019 ipython --pdb -i -- $(which $py) ${@:2}
0020 }
0021
0022 For example::
0023
0024 ip tboolean.py --tagoffset 0 --tag 1 --cat tboolean-box --pfx tboolean-box --src torch --show
0025
0026 """
0027 import logging
0028 log = logging.getLogger(__name__)
0029
0030 try:
0031 from IPython.core.debugger import Pdb as MyPdb
0032 except ImportError:
0033 class MyPdb(object):
0034 def set_trace(self):
0035 log.error("IPython is required for ipdb.set_trace() " )
0036 pass
0037 pass
0038 pass
0039
0040
0041 if __name__ == '__main__':
0042 logging.basicConfig(level=logging.INFO)
0043 ipdb = MyPdb()
0044 ipdb.set_trace()
0045
0046