Jul 25, 2012

Django model visualization, dependency graph generator, call graphs

django-command-extensions - model visualization with pygraphviz:
pip install django-extensions
pip install pygraphviz

# add 'django_extensions' to INSTALLED_APPS

# all models from INSTALLED_APPS (django too)
./manage.py graph_models -a -g -o my_project.png  

# just two apps: emailing and localization 
./manage.py graph_models -g -e -l dot -o my_project.png emailing localization

# all project packages (without django; assumed packages in apps folder
./manage.py graph_models -g -e -l dot -o my_project.png  `ls -ld apps/* | grep "^d"|awk '{print $9}'| sed s/'apps\/'// | xargs`

django-detect-cyclic - application to detect cyclic imports. With this application you can analyze the dependence of your applications
pycallgraph - a Python module that creates call graphs for Python programs

snakefood - a dependency graph generator for Python source code

filtering and clustering dependencies
sfood /my_project/apps -i | sfood-cluster -f clusters | sfood-graph > my_package.dot
dot -Tpng -Ktwopi -O my_package.dot


Pyreverse - analyses Python code and extracts UML class diagrams and package dependencies
sudo apt-get install pylint
pyreverse -o png -A -s 0 -a 0 -k  apps/designer/ apps/core apps/company/ --ignore=migrations,tests,tests.py
pyreverse -o png --ignore=migrations,tests apps/interiors/

Gprof2Dot - Convert profiling output to a dot graph. dependencies
Python cProfile (formerly known as lsprof)
python -m cProfile -o output.pstats path/to/your/script arg1 arg2
gprof2dot.py -f pstats output.pstats | dot -Tpng -o output.png

No comments: