New from O’Reilly: The memory architecture behind adaptive AI agents

Read the report
For developersExplore Python Codebase using RedisGraph
Ajeet Raina
Ajeet Raina

END-OF-LIFE NOTICE

Redis is phasing out RedisGraphThis blog post explains the motivation behind this decision and the implications for existing Redis customers and community members.

End of support is scheduled for January 31, 2025.

Beginning with Redis Stack 7.2.x-y, Redis Stack will no longer include graph capabilities (RedisGraph).

Pycograph is an open source tool that creates a RedisGraph model of your Python code. The tool lets you to explore your Python codebase with graph queries. With Pycograph, you can query the python code with Cypher. Additionally, it is possible to visualize the graph model using RedisInsight.

The project is hosted over https://pycograph.com/ and package is available in PyPI repository. It was introduced for the first time by Reka Horvath during RedisConf 2021.

Let us see how to explore Python code using Pycograph and RedisGraph below:

Step 1. Install Docker

Step 2. Install Pycograph from PyPI

Step 3. Start RedisGraph Module

The redis/redis-stack Docker image provides you all the essential Redis modules.

Step 4. Run RedisInsight

Step 5. Load a sample Python code

We will be using a popular Docker compose project for our sample python code. Clone the Docker Compose project repository

Step 6. Load Python Code

Load your project's code with the pycograph load command:

Results:

Step 7. Visualize the project

Open RedisInsight, select RedisGraph on the left menu and run the below query:

Query #1: Return every node

You will see the below output:

Image

Query #2: Return every non-test object

Image

Query #3. Displaying the function behind the docker-compose up command

A query returning exactly one node using the unique full_name property. Double-click on the node to display all its relationships.

Image

Query #4. Displaying the 'docker-compose up' and its calls relationships

Image

Query #5. Displaying the 'docker-compose up' vs 'docker-compose run'

Image

References:

Image

Functions called by the Docker Compose top level commands up and run