Skip to main content

vscode-debug-visualizer extension for python

Project description

This package adds python support to the Debug Visualizer.

Installation Instructions

The Debug Visualizer is required. To install the extension for python, your're required to install the package within your debug enviroment:

pip install vscodedebugvisualizer

supported Types

Numpy Array / PyTorch Tensors / Tensorflow Tensors

All Tensors are converted to numpy arrays and treated alike.

If there multiple dimensions only the last 2 dimensons are visualized, the longer dimension ist treated as x axis. The X axe is downsampled to 1000 points and the y axe only shows the first 10 rows.

Dataframes

Dataframes are transformed to data tables.

Add your own representation/data extractor

Asuming you have a specific Type in your project you want to visualize. You can create a file debugvisualizer.py in your project root directory, that will be injected into the debug process.

Asuming we want to visualize the class Person:

class Person:
    def __init__(self, name, parents=None) -> None:
        self.name = name
        self.parents = [] if parents is None else parents

    def addParent(self, parent: "Person"):
        self.parents.append(parent)

In debugvisualizer.py you can access all available visualizer with the from vscodedebugvisualizer import globalVisualizationFactory. To support your Type you need to create an class that has checkType(anytype) -> Boolean and visualize(self, data) -> None defined. checkType should return True if the given object is supported by the Visualizer. visualize returns a json string that is supported by the visualizer client (see playground).

Finally you need to add the visualizer to the globalVisualizationFactory with globalVisualizationFactory.addVisualizer(YourVisualizer()).

For the Person-Example:

from Person import Person
from pandas.io import json
from vscodedebugvisualizer import globalVisualizationFactory


class PersonVisualizer:
    def checkType(self, t):
        """ checks if the given object `t` is an instance of Person """
        return isinstance(t, Person)

    def visualizePerson(self, person: Person, nodes=[], edges=[]):
        if person.name in [n["id"] for n in nodes]:
            return nodes, edges

        nodes.append(
            {
                "id": person.name,
                "label": person.name,
            }
        )

        for p in person.parents:
            nodes, edges = self.visualizePerson(p, nodes, edges)
            edges.append(
                {
                    "from": p.name,
                    "to": person.name,
                }
            )

        return nodes, edges

    def visualize(self, person: Person):
        jsonDict = {
            "kind": {"graph": True},
            "nodes": [],
            "edges": [],
        }

        self.visualizePerson(person, jsonDict["nodes"], jsonDict["edges"])

        return json.dumps(jsonDict)


globalVisualizationFactory.addVisualizer(PersonVisualizer())

For more visualization examples check out the visualizer playground

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vscodedebugvisualizer-0.2.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vscodedebugvisualizer-0.2.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file vscodedebugvisualizer-0.2.1.tar.gz.

File metadata

  • Download URL: vscodedebugvisualizer-0.2.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for vscodedebugvisualizer-0.2.1.tar.gz
Algorithm Hash digest
SHA256 715b16fe44dcf179f621bae13792a7552a32700b82c52cc18d371b3f991e48b4
MD5 d0dc5331ef5208a4eda9dcd70559e748
BLAKE2b-256 981578ba826da84318fcddeca4c01cd43e26865105bb33223fcab1b12326da37

See more details on using hashes here.

File details

Details for the file vscodedebugvisualizer-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for vscodedebugvisualizer-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 593a16d77c313b93471cfa7a4701b479c6aebbe6f27f7dc7f446db9c811e2ed7
MD5 fe2118895fff5602c90e8bee0eeeb0f5
BLAKE2b-256 b6c45ecc7e1b8abb6258a9c5d38673435e1d0800e8d62c377d629af0f2b16d04

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page