Spaces:
Runtime error
Runtime error
add aiocache
Browse files- README.md +1 -0
- app.py +8 -6
- py_code_analyzer/code_imports_analyzer.py +1 -1
- requirements.txt +5 -0
README.md
CHANGED
|
@@ -30,6 +30,7 @@ among files included in the directory with better visualization.
|
|
| 30 |
- `networkx`: network analysis
|
| 31 |
- `pyvis`: network visualization
|
| 32 |
- `aiohttp`: asynchronous HTTP client
|
|
|
|
| 33 |
- `pybase64`: faster base64 encoding/decoding
|
| 34 |
- `streamlit`: web app
|
| 35 |
|
|
|
|
| 30 |
- `networkx`: network analysis
|
| 31 |
- `pyvis`: network visualization
|
| 32 |
- `aiohttp`: asynchronous HTTP client
|
| 33 |
+
- `aiocache`: caching asynchronous API requests
|
| 34 |
- `pybase64`: faster base64 encoding/decoding
|
| 35 |
- `streamlit`: web app
|
| 36 |
|
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
|
| 4 |
import streamlit as st
|
| 5 |
import streamlit.components.v1 as components
|
|
|
|
| 6 |
|
| 7 |
from py_code_analyzer import CodeFetcher, CodeImportsAnalyzer, ImportsGraphVisualizer
|
| 8 |
from utils import conditonal_decorator, time_function
|
|
@@ -37,22 +38,23 @@ st.markdown("---")
|
|
| 37 |
|
| 38 |
@st.cache
|
| 39 |
@conditonal_decorator(time_function, DEV)
|
| 40 |
-
def get_python_files(owner, repo, tree_sha):
|
| 41 |
return CodeFetcher().get_python_files(owner, repo, tree_sha)
|
| 42 |
|
| 43 |
|
|
|
|
| 44 |
@conditonal_decorator(time_function, DEV)
|
| 45 |
-
def parse_python_files(analyzer):
|
| 46 |
-
|
| 47 |
|
| 48 |
|
| 49 |
@conditonal_decorator(time_function, DEV)
|
| 50 |
-
def generate_imports_graph(analyzer):
|
| 51 |
return analyzer.generate_imports_graph()
|
| 52 |
|
| 53 |
|
| 54 |
@conditonal_decorator(time_function, DEV)
|
| 55 |
-
def generate_graph_visualization_file(imports_graph, heading):
|
| 56 |
ImportsGraphVisualizer().visualize(imports_graph, heading=heading)
|
| 57 |
|
| 58 |
|
|
@@ -67,7 +69,7 @@ if clicked_ok_button and owner and repo:
|
|
| 67 |
|
| 68 |
analyzer = CodeImportsAnalyzer(python_files)
|
| 69 |
with st.spinner("Parsing python files..."):
|
| 70 |
-
parse_python_files(analyzer)
|
| 71 |
|
| 72 |
with st.spinner("Generating imports graph..."):
|
| 73 |
imports_graph = generate_imports_graph(analyzer)
|
|
|
|
| 3 |
|
| 4 |
import streamlit as st
|
| 5 |
import streamlit.components.v1 as components
|
| 6 |
+
from aiocache import Cache, cached
|
| 7 |
|
| 8 |
from py_code_analyzer import CodeFetcher, CodeImportsAnalyzer, ImportsGraphVisualizer
|
| 9 |
from utils import conditonal_decorator, time_function
|
|
|
|
| 38 |
|
| 39 |
@st.cache
|
| 40 |
@conditonal_decorator(time_function, DEV)
|
| 41 |
+
def get_python_files(owner: str, repo: str, tree_sha: str):
|
| 42 |
return CodeFetcher().get_python_files(owner, repo, tree_sha)
|
| 43 |
|
| 44 |
|
| 45 |
+
@cached(ttl=None, cache=Cache.MEMORY)
|
| 46 |
@conditonal_decorator(time_function, DEV)
|
| 47 |
+
async def parse_python_files(analyzer: CodeImportsAnalyzer):
|
| 48 |
+
_ = await analyzer.parse_python_files()
|
| 49 |
|
| 50 |
|
| 51 |
@conditonal_decorator(time_function, DEV)
|
| 52 |
+
def generate_imports_graph(analyzer: CodeImportsAnalyzer):
|
| 53 |
return analyzer.generate_imports_graph()
|
| 54 |
|
| 55 |
|
| 56 |
@conditonal_decorator(time_function, DEV)
|
| 57 |
+
def generate_graph_visualization_file(imports_graph, heading: str):
|
| 58 |
ImportsGraphVisualizer().visualize(imports_graph, heading=heading)
|
| 59 |
|
| 60 |
|
|
|
|
| 69 |
|
| 70 |
analyzer = CodeImportsAnalyzer(python_files)
|
| 71 |
with st.spinner("Parsing python files..."):
|
| 72 |
+
asyncio.run(parse_python_files(analyzer))
|
| 73 |
|
| 74 |
with st.spinner("Generating imports graph..."):
|
| 75 |
imports_graph = generate_imports_graph(analyzer)
|
py_code_analyzer/code_imports_analyzer.py
CHANGED
|
@@ -68,7 +68,7 @@ class CodeImportsAnalyzer:
|
|
| 68 |
self.python_files = python_files
|
| 69 |
self._node_visitor = CodeImportsAnalyzer._NodeVisitor(self.python_imports)
|
| 70 |
|
| 71 |
-
async def
|
| 72 |
async with aiohttp.ClientSession() as session:
|
| 73 |
tasks = []
|
| 74 |
for python_file in self.python_files:
|
|
|
|
| 68 |
self.python_files = python_files
|
| 69 |
self._node_visitor = CodeImportsAnalyzer._NodeVisitor(self.python_imports)
|
| 70 |
|
| 71 |
+
async def parse_python_files(self):
|
| 72 |
async with aiohttp.ClientSession() as session:
|
| 73 |
tasks = []
|
| 74 |
for python_file in self.python_files:
|
requirements.txt
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
|
|
| 1 |
aiodns==3.0.0
|
| 2 |
aiohttp==3.8.1
|
|
|
|
|
|
|
| 3 |
aiosignal==1.2.0
|
| 4 |
altair==4.2.0
|
| 5 |
appnope==0.1.3
|
|
@@ -62,6 +65,7 @@ MarkupSafe==2.1.1
|
|
| 62 |
matplotlib-inline==0.1.3
|
| 63 |
mccabe==0.6.1
|
| 64 |
mistune==0.8.4
|
|
|
|
| 65 |
multidict==6.0.2
|
| 66 |
mypy==0.960
|
| 67 |
mypy-extensions==0.4.3
|
|
@@ -131,6 +135,7 @@ traitlets==5.2.2.post1
|
|
| 131 |
typing_extensions==4.2.0
|
| 132 |
tzdata==2022.1
|
| 133 |
tzlocal==4.2
|
|
|
|
| 134 |
urllib3==1.26.9
|
| 135 |
validators==0.20.0
|
| 136 |
virtualenv==20.14.1
|
|
|
|
| 1 |
+
aiocache==0.11.1
|
| 2 |
aiodns==3.0.0
|
| 3 |
aiohttp==3.8.1
|
| 4 |
+
aiomcache==0.7.0
|
| 5 |
+
aioredis==2.0.1
|
| 6 |
aiosignal==1.2.0
|
| 7 |
altair==4.2.0
|
| 8 |
appnope==0.1.3
|
|
|
|
| 65 |
matplotlib-inline==0.1.3
|
| 66 |
mccabe==0.6.1
|
| 67 |
mistune==0.8.4
|
| 68 |
+
msgpack==1.0.4
|
| 69 |
multidict==6.0.2
|
| 70 |
mypy==0.960
|
| 71 |
mypy-extensions==0.4.3
|
|
|
|
| 135 |
typing_extensions==4.2.0
|
| 136 |
tzdata==2022.1
|
| 137 |
tzlocal==4.2
|
| 138 |
+
ujson==5.3.0
|
| 139 |
urllib3==1.26.9
|
| 140 |
validators==0.20.0
|
| 141 |
virtualenv==20.14.1
|