File size: 1,945 Bytes
813f6f8
 
 
 
 
 
 
 
 
 
 
 
 
 
23072f6
 
 
 
 
 
 
231b6fa
 
0762638
231b6fa
 
23072f6
 
 
231b6fa
 
5260136
 
231b6fa
 
 
a908fc5
82531de
 
231b6fa
 
 
 
1903343
deb90b0
d48fa34
 
 
 
 
a908fc5
 
 
d48fa34
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
title: Py Code Analyzer
emoji: πŸ“ˆ
colorFrom: red
colorTo: yellow
sdk: streamlit
sdk_version: 1.9.0
app_file: app.py
pinned: false
license: mit
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference

# Python Code Analyzer

## Motivation

The main purpose of the app is to allow Python developers navigate Python code base much easier by showing dependencies
among files included in the directory with better visualization.

## Setup

- `pipenv install -r requirements.txt --python=3.8`
- `cp .env.example .env`: fill in your GitHub username and personal access token if you need to increase [GitHub API requests rate limiting](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting)
- `make run`

## Used technologies

- `networkx`: network analysis
- `pyvis`: network visualization
- `aiohttp`: asynchronous HTTP client
- `pybase64`: faster base64 encoding/decoding
- `streamlit`: web app

## TODOs

- [x] Build a prototype
  - [x] Finish `generate_imports_graph` implementation
  - [x] Fetch python files given public GitHub repo url(owner, repo, path, ref)
  - [x] Use `ast` to parse imports among given python files
  - [x] Generate a basic `networkx` graph given python imports
  - [x] Visualize a basic `networkx` graph using `pyvis`
- [x] Build a `streamlit` app
- [ ] Performance optimization
  - [x] `requests` to `aiohttp`
  - [x] change fetching GitHub repository content api from preventing querying multiple times
  - [ ] ...
- [ ] Network analysis
- [ ] Enhance network visualization UI
## References

- [How to set up a perfect Python project](https://sourcery.ai/blog/python-best-practices/)
- [Benchmark of popular graph/network packages](https://www.timlrx.com/blog/benchmark-of-popular-graph-network-packages)
- [Asynchronous HTTP Requests in Python with aiohttp and asyncio](https://www.twilio.com/blog/asynchronous-http-requests-in-python-with-aiohttp)