scottrogowski / code2flow

Pretty good call graphs for dynamic languages
MIT License
3.92k stars 286 forks source link

Having problem to get bigger graphs #75

Closed titusfx closed 1 year ago

titusfx commented 1 year ago

Using the following command

code2flow main.py --target-function main --upstream-depth=10 --downstream-depth=10

my result is: out

and my main.py code is

from video_generator import VideoGenerator
from typing import NamedTuple

def main(url: str):
    # create_video(url)
    vg = VideoGenerator()
    vg.create_video(url)

Log code2flow


Code2Flow: Found 1 files from sources argument.
Code2Flow: Implicitly detected language as 'py'.
Code2Flow: Processing 1 source file(s).
Code2Flow:   main.py
Code2Flow: Found groups ['File: main', 'Class: EditVideoConfiguration'].
Code2Flow: Found nodes ['(global)', 'gap_amount', 'main', 'overlay_audios'].
Code2Flow: Found calls ['EditVideoConfiguration()', 'VideoGenerator()', 'final_audio_parts.append()', 'gap_amount()', 'lower_volume_original_audio.overlay()', 'main()', 'sum()', 'vg.create_video()', 'zip()'].
Code2Flow: Found variables ['NamedTuple->UNKNOWN_MODULE', 'VideoGenerator->UNKNOWN_MODULE', 'config->EditVideoConfiguration', 'overlay_audio-><Call owner_token=lower_volume_original_audio token=overlay>', 'vg-><Call owner_token=None token=VideoGenerator>'].
Code2Flow: Filtering into subset...
Code2Flow: Generating output file...
Code2Flow: Wrote output file 'out.gv' with 2 nodes and 14 edges.
Code2Flow: For better machine readability, you can also try outputting in a json format.
Code2Flow: Code2flow finished processing in 0.00 seconds.
Code2Flow: Running graphviz to make the image...
Code2Flow: Graphviz finished in 0.04 seconds.
Code2Flow: Completed your flowchart! To see it, open 'out.png'.
scottrogowski commented 1 year ago

You’re only including one file in the analysis - main.py. Try also including your video_generator file

titusfx commented 1 year ago

I tried to include also the directory:

line 162, in get_tree return ast.parse(raw) File "/usr/lib/python3.10/ast.py", line 50, in parse return compile(source, filename, mode, flags, File "", line 34 get src attribute and download link ^ SyntaxError: invalid decimal literal

And I can't find a way to include only two files or three... In any case, it doesn't feel intuitive that is required to add the files that you want to analyze when you are specifying one file. I thought that the idea of having a depth was related with that.