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 vscodedebugvisualizerpy
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file vscodedebugvisualizer-0.1.0.tar.gz
.
File metadata
- Download URL: vscodedebugvisualizer-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.8.0 tqdm/4.53.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad476f6c97457b60774837cda9dd4e9532b2dbaa2b9b944586102db0bc095013 |
|
MD5 | 8da97cc4da06f498f6d24bbdcdc2bb7c |
|
BLAKE2b-256 | 94a6629b8396c94871c40e9de93055bea06776f499d8951a4cb9a28b78a90873 |
File details
Details for the file vscodedebugvisualizer-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: vscodedebugvisualizer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.8.0 tqdm/4.53.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f2382690b02c4807c898ea9b42eecb7fd351236ed9fc613662f930a7be15159 |
|
MD5 | bcfed531914e4a504cbf7a543f7f8c00 |
|
BLAKE2b-256 | 11dbaf4a6e29b431f1db4e662a18d1da27d32aed774d786577e79e24e9370484 |