Skip to main content

No project description provided

Project description

Pycograph

Pycograph

Explore your Python code with graph queries

Pycograph creates a RedisGraph model of your Python code. You can:

sample Redis Insight result

Getting Started

Install Pycograph from PyPI:

pip install pycograph

Start a Redis instance with the RedisGraph module 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

Visit your RedisInstance at http://localhost:8001 in a browser.
Connect to your local Redis database.

Create a RedisGraph model of your project's code with the pycograph load command:

pycograph load --project-dir ~/code/your-project --test-types

By default, if you don't provide the --project-dir option, Pycograph tries to find Python code in the current working directory.

Run a query in RedisInsight. E.g.

GRAPH.QUERY "your-project" "MATCH (n) return n"

Options

  • --project-dir: The root directory of the Python project you want to analyze. If you omit this option, Pycograph will search for .py files in your current working directory.
  • --graph-name: Specifies the name of the generated graph. Default: the name of the project directory.
  • --overwrite: If a graph with this name exists overwrite it. If you don't provide this flag, the new nodes and edges will be appended to the graph.
  • --test-types: Determine the types of tests based on the subdirectories of the tests directory.
  • --redis-host: The host of the Redis instance. Default: localhost
  • --redis-port: The port of the Redis instance. Default: 6379
  • --version: Print Pycograph version and exit.

Limitations

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.

Imports

The following imports will be ignored by Pycograph:

  • imported external packages
  • import * syntax
  • variables
  • globals

Calls

  • All the limitations of the imports.
  • Resolving longer calls of more than 2 levels.

Other Known Limitations

  • No support for .py files containing Jinja templates (e.g. cookiecutter)

How Does It Work?

flow of loading code: source => RedisGraph

Libraries used:

  • 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

Contributing

see the Contributing guide

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

pycograph-0.2.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

pycograph-0.2.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file pycograph-0.2.2.tar.gz.

File metadata

  • Download URL: pycograph-0.2.2.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.8.0-50-generic

File hashes

Hashes for pycograph-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ec659a110dec9464c2f39b98eb9f90a3e1afff1d7173f7f8472720f79d9cb3c1
MD5 48c0b5eec4909282caa54629d7c7e352
BLAKE2b-256 fc7069238aaaeaef613e28df1ff558e847b27a87b10bc1a07680d50910f7ae67

See more details on using hashes here.

File details

Details for the file pycograph-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: pycograph-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.8.0-50-generic

File hashes

Hashes for pycograph-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f3e199401d63c4e552214742a82cc4de0d101a92c04eaed964212d598f3891c
MD5 6f7114239befdbb14c343d764c8f4710
BLAKE2b-256 4869f90c5aff854ab41402c36a1a9a1c322c1bac1e60ccca1c0be4a2a0275ba4

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