Explore your Python code with graph queries
Pycograph creates a RedisGraph model of your Python code. You can:See some examples
Install Pycograph from PyPI:
pip install pycograph
Start RedisGraph and RedisInsight. E.g. via Docker containers:
docker run -d -p 6379:6379 redislabs/redismod
docker run -d -v redisinsight:/db -p 8001:8001 redislabs/redisinsight:latest
Load your project's code with the
pycograph load command:
See some examples
pycograph load --project-dir ~/code/docker/compose
Pycograph's current model:
In the current model, each node has exactly one label.
Properties for all nodes
- reference_type: absolute / relative
How Does It Work?
You can find the source code on GitHub.
- ast module of the Python standard library for the abstract syntax tree
- Pydantic both for the models of the intermediate objects and for the settings
- redisgraph-py for creating the RedisGraph model
- typer for the command line interface
Pycograph is in beta version.
It creates a basic model with focus on the relationships betweeen the different parts of the code base. Even that model might be incomplete, ignoring some less common syntax. The goal is to provide some useful insight, not to create an exhaustive model.
If Pycograph finds a syntax error, it skips the module containing the syntax error and tries to build a model from the rest of the code base.
Below are some of the limitations. If you bump into other limitations, please open a GitHub issue.
The following imports will be ignored by Pycograph:
- imported external packages
- All the limitations of the imports.
- Resolving calls of more than 2 levels.
Other Known Limitations
- No support for
.pyfiles containing Jinja templates (e.g. cookiecutter)
Pycograph is a tool for exploration. Its goal is to provide insight, not to take decisions. It shouldn't trigger automated code changes or cleanup.