Comments (6)
Hi,
No, there's no specific style Pyan expects. It actually converts the source code to an AST using ast.parse
and analyzes that, so if Python itself can understand the program, then Pyan should be able to understand most of it.
Python is a large language, though, and some features are not supported. See the README for a list, under the heading "The analyzer does not currently support". It should be complete, but hasn't been updated lately, so features new in 3.7 or 3.8 may be missing from it.
If you put all the Python files on the command line, Pyan should analyze and graph all of them, including any references between them. It sounds like Pyan is not reading your main program correctly for some reason.
Could you try modvis.py -cag --dot
(here) on your files to see if it can generate a graph of how your modules depend on each other? If it works while Pyan itself produces a blank graph, then it could be a problem in Pyan's import analyzer.
Or try Pyan with the --very-verbose
command line flag and look at the output, it might help see what's going on?
(For debugging, you can omit the --dot
flag for Pyan. The visual graph generation is a separate postprocessing step, and this sounds like something is going wrong already in the analysis.)
from pyan.
For modvis , it outputs:
digraph G {
graph [rankdir=TB, clusterrank="local"];
subgraph cluster_G {
graph [style="filled,rounded",fillcolor="#80808018", label=""];
}
}
For verbose mode, it outputs:
========== pass 1, file 'MYFILE.py' ==========
Scopes now: {'MYFILE': <Scope: module >}
Module
Resolving base classes
All base classes (non-recursive, local level only): {}
Resolving method resolution order (MRO) for all analyzed classes
Method resolution order (MRO) for all analyzed classes: {}
========== pass 2, file 'MYFILE.py' ==========
Scopes now: {'MYFILE': <Scope: module >}
Module
<class 'pyan.writers.DotWriter'> running
Start subgraph
Finish subgraph
from pyan.
Thanks for testing. So, both tools produce an empty graph. It's probably not the import analyzer, then.
(I forgot to mention, modvis.py
also supports --very-verbose
, which should tell about the import statements it sees. Likewise, omitting --dot
is possible, modvis.py
too generates the graph in a separate postprocessing step. In your case, there should probably be an import in MYFILE.py
that loads your library.)
Pyan is behaving as if it didn't see any of the code in MYFILE.py
. There should be quite many log messages printed, at least one for each function or class encountered. The lack of any scopes other than the module top level also suggests it's not seeing any class/function definitions for some reason.
Which Pyan version are you running? Is it from PyPI, or directly from this GitHub repo? There are a few small fixes that haven't yet been packaged (nor pushed to davidfraser's stable repo), so one possible thing to try is the latest Pyan from git, unless you tried it already.
Other than that... I'm guessing here, but maybe language version compatibility? Do you have a virtualenv (or Anaconda, or equivalent) where you could easily run Pyan in Python 3.6?
(Your own program doesn't need to run in 3.6. Pyan running in 3.6 can analyze the code as long as it doesn't use any new syntax that only exists in Python 3.7 or later. Off the top of my head, I can't recall any new syntax in 3.7 or 3.8 - there was an internal AST representation change in 3.8 (the compiler now produces ast.Constant
nodes instead of ast.Num
and ast.Str
for constants), but the surface syntax, i.e. what we actually write in .py
files, should be the same from 3.6 to 3.8.)
If, like me, you happen to be new to the virtualenv stuff... coming from a science background, here are the commands for Anaconda, see points 3-6. Last I looked, the Python ecosystem provided a bewildering variety of virtualenv options, each slightly different, and I'm not sure if the dust has settled yet, so to speak. If you are already familiar with another virtualenv system, just use that - it shouldn't matter.
Testing this just needs any virtualenv with Python 3.6. Then get the latest Pyan from this GitHub repo, python3 setup.py install
it in the virtualenv, and try analyzing your code with it.
from pyan.
Ah, one more thing: character encoding of your .py
files? Pyan currently assumes utf-8
.
from pyan.
very verbose didnt change anything on modvis.
I'm using the IDLE editor on windows to write and run the script, so whatever is the default there.
I have no idea why, but I put the most recent version of my code in, and tried again and it seems to work now. Very strange.
from pyan.
I have no idea of Windows defaults, that's why I asked. :)
(If you ask me, nowadays everyone should be using utf-8
. Unicode is the single huge codepage for the 21st century, while utf-8
is its sanest encoding. But its rates of adoption have historically varied between different OSs and software.)
Glad that you got it working!
from pyan.
Related Issues (20)
- __init__() got multiple values for argument 'root' HOT 8
- Integrate modvis.py to main pyan executable
- BrokenPipeError
- Call graph from file contents
- Different order for edges between different calls when several source files are provided
- got multiple values for argument 'root' after upgrade 1.1.1 -> 1.20 HOT 5
- Feature Suggestion: Customize depth (level) of generated graph
- Sphinx integration HOT 1
- FileNotFoundError: [Errno 2] No such file or directory: '' HOT 2
- Tutorial or document
- Is the project still maintained? HOT 4
- Would like to generate call graph for a very basic file HOT 2
- What is "dot"? HOT 1
- Call graphs are wrong -- don't respect namespaces
- [question] What is the intended purpose of white module nodes?
- cannot have a file called โGraph.pyโ that has module level call to a known function HOT 1
- Unable to use Pyan HOT 2
- issue with list comprehension in python 3.12 HOT 5
- Help wanted - sign up here! HOT 5
- CallGraphVisitor wrong parameters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyan.