objgraph

repository·master·Indexed 21 days ago

https://github.com/mgedmin/objgraph

A Python module used to visually explore and navigate Python object graphs, primarily for debugging and identifying memory leaks. It supports Python 2.7 and 3.5+ and integrates with Graphviz and xdot for visual graph rendering.

Tokens
823
Snippets
9
Records
10
Agent score
24%

What's inside objgraph

  1. Rebuild documentation and images

    master

    To fully rebuild the project documentation and all associated images, run:

    make clean images docs

    Note: When committing changes, use git checkout -- docs/*.png for images that haven't changed significantly, as memory addresses in images often change between runs.

  2. Set up the objgraph development environment

    master

    To start contributing to objgraph, clone the repository and run the test suite to ensure everything is working correctly.

    # Clone the source
    git clone https://github.com/mgedmin/objgraph
    
    # Run the test suite
    make test
    git clone https://github.com/mgedmin/objgraph
    make test
  3. Check test coverage

    master

    To see how much of the code is covered by the existing (mostly smoke) tests, use the coverage tool via the provided Makefile command.

    To view a text-based summary:

    make coverage

    To generate an HTML report:

    make coverage
    coverage html

    Then browse the results in htmlcov/index.html.

  4. Install dependencies for visual graph rendering

    master

    To draw pretty graphs, you must have graphviz installed on your system. For interactive use, it is recommended to install xdot. objgraph will automatically look for xdot in your PATH.

    pip install xdot
  5. Follow docstring standards for objgraph

    master

    All new functions must have a PEP-257 compliant docstring. When adding them, ensure you add the appropriate autodoc directive to objgraph.txt.

    Docstring Formatting Rules:

    1. Closing Triple Quotes: The closing """ should not be preceded by a blank line.
      def do_something():
          """Do something.
      
          Return something valuable.
          """
    2. Indented Blocks: If the last part of a docstring is an indented block quote or a doctest, it must be surrounded by blank lines.
      def do_something():
          """Do something.
      
          Return something valuable.
      
          Example:
      
              >>> do_something()
              42
      
          """
    def do_something():
        """Do something.
    
        Return something valuable.
        """
  6. Debug test failures visually using images

    master

    Since many tests are verified by inspecting generated images, you can debug failures by comparing visual output. Use make images with a specific Python version and imgdiff to see the differences.

    # Generate images for a specific Python version
    make images PYTHON=pythonX.Y
    
    # Configure git to use imgdiff for visual comparison
    git config diff.imgdiff.command 'f() { imgdiff --eog -H $1 $2; }; f'
    
    # Compare the generated images
    git diff docs/*.png
    make images PYTHON=pythonX.Y
    git config diff.imgdiff.command 'f() { imgdiff --eog -H $1 $2; }; f'
    git diff docs/*.png