Thursday, July 31, 2014

Debugging Python using ipdb

We can install ipdb (interactive python debugger) via pip
$ pip install ipdb
To insert a breakpoint (hard coded break points) in the code use ipdb.set_trace(). You can insert many breakpoints as you like. To run the code:
$ python mycode.py
When the breakpoint is hit, you will be dropped to ipdb prompt, similar to the ipython prompt. Use "c" (continue) command to continue the code until the next breakpoint or until the program ends.

For example,


import sparsesvd
import ipdb

def f(x):
    print x
    y = 2 *x 
    ipdb.set_trace()
    print y
    z = y * 3
    ipdb.set_trace()
    print z
    pass

if __name__ == "__main__":
    f(10)
    print "all done"

Wednesday, July 30, 2014

Bitbucket with SSH

If you want to access bitbucket via SSH instead of https, upload the SSH RSA public key to bitbucket. Then use the following path for example when cloning.

git clone ssh://git@bitbucket.org/Bollegala/SupEmb.git

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1