Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: identify a tool for selectively building dependency graph #26

Open
GavinHuttley opened this issue Mar 7, 2023 · 1 comment
Open
Assignees

Comments

@GavinHuttley
Copy link
Collaborator

Use case here is we have some modules that need eventually to be removed as they duplicate functionality in other libraries on which we already depend. However, given the size of those modules it is rather daunting to approach the problem.

We need the ability to create a dependency graph that is conditioned on a specific module so we can understand where it is being used.

The specific use case is cogent3.maths.stats.special.

@khiron
Copy link
Collaborator

khiron commented Mar 20, 2023

2 tools

https://github.com/thebjorn/pydeps
and
https://github.com/khiron/snakefood3

Pydeps is more polished/featured featured. It reads bytecode from .pyc files to extract out all actual imports (vs declared imports in the source) and integrates with an installed instance of Graphviz to generate Dot language text describing the graph, and render it as an .svg image file. It's a bit messier to set up as you have to have Graphviz set up just so.

Snakefood3 is a python3 update of a python classic dependency graph tool Snakefood. It's almost the simplest possible program to do the task, it uses your current pythons own AST to read .py file, extracts out all declared imports into a dictionary, and uses a jinja2 template to output to STDOUT Dot language text describing the graph. That then needs to be manually visualized using Graphviz. The reason I forked the repo is I am working on getting it to output graphs in mermaid formatted .md files which can be directly visualized in both Github and modern IDEs and I can dispatch with the unnecessary complexity of Graphviz.

Both can be centered on a specific module within a dependency. Either will do the required job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants