Skip to content

Commit

Permalink
addning new helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mike dupont committed Oct 22, 2023
1 parent a61d112 commit b196b7c
Show file tree
Hide file tree
Showing 7 changed files with 59,466 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pyre/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ published in webpage: https://jmikedupont2.github.io/ai-ticket/pyre/

this is not working yet
`pyre-check query "types_in_file('tests.py')"`


# calls3
produces a report with module and called function

# calls_generic.py
like call2.py but takes a name
28 changes: 28 additions & 0 deletions pyre/calls3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from collections import Counter
import pandas as pd
data=[]
import glob, json
names = "./report/*/report/pyre_callgraph.json"
#pyre_callgraph.json"

files = {}
calls=[]
for name in glob.glob(names):
print(name)
name2 = name.replace("/report/pyre_callgraph.json","").replace("./report/","")
with open(name) as fi :
for x in fi:
d = json.loads(x)
data = d["response"]
for x in list(data.keys()): # each function
if (len(data[x])):
for y in data[x]:
if "direct_target" in y:
calls.append( name2 +"|"+ y["direct_target"])
df= Counter(calls)
df2=pd.DataFrame(df.most_common(), columns=["name","count"])

df2[['name','func']] = df2['name'].str.split('|',expand=True)
#df[[]] = df['fun'].str.split('.',expand=True)

df2.to_csv("function_calls3.csv")
31 changes: 31 additions & 0 deletions pyre/calls_generic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import click
from collections import Counter
import pandas as pd
data=[]
import glob, json

@click.command()
@click.argument('name')
def main(name):
names = f"./report/{name}/report/pyre_callgraph.json"
files = {}
calls=[]
for name in glob.glob(names):
print(name)
with open(name) as fi :
for x in fi:
d = json.loads(x)
data = d["response"]
for x in list(data.keys()): # each function
if (len(data[x])):
for y in data[x]:
if "direct_target" in y:
calls.append( x +"|"+ y["direct_target"])
df= Counter(calls)
df2=pd.DataFrame(df.most_common(), columns=["name","count"])
ofile = name + "function_calls2.csv"
print(ofile)
df2.to_csv(ofile)

if __name__ == "__main__":
main()
468 changes: 468 additions & 0 deletions pyre/function_calls.csv.html

Large diffs are not rendered by default.

468 changes: 468 additions & 0 deletions pyre/function_calls2.csv.html

Large diffs are not rendered by default.

Loading

0 comments on commit b196b7c

Please sign in to comment.