thebjorn/pydeps

Possibility to collapse submodules of the target module

Closed this issue ยท 4 comments

Hey! I'm not sure whether this is an open issue, I tried my hardest to find an existing issue covering a similar request.

I've used pydeps on smaller packages and its great. However, for a large monolithic package, it is hard to get any useful insights in the clutter. What I'm trying to do is gain insight in how dependent various components of my codebase rely on one another, and where I could attempt to try to decouple submodules more and more. Concretely, say I have a large monolithic codebase with root module name company. Then I have a module structure as

company
 |- project_a
    |- class_a_1
    |- class_a_2
 |- project_b
    |- endpoint_b_1
    |- endpoint_b_2
 |- project_c
    |- adapter_a_1
    |- adapter_a_2
 |- util
    |- utility_a
    |- utility_b
 |- database
 |- ....

As I stated, there's a large amount of interdependencies, that I'd like to minimise. However, since the project is large (and the example modules would be subdivided many times over), it is not useful to use pydeps to obtain a good overview of these dependencies. However, if I could collapse modules within, say, a depth of 2 within my root module, I would image I obtain a smaller graph that I can properly use as a basis for a large refactor.

As such, I would like to ask if it is possible to add a flag --collapse-root-depth DEPTH (or similar) to do this very operation.

Thank you for taking the time to read in consider, and thanks for this tool!

Hugo-C commented

@RobbinDG you shoud try:

pydeps <root-module> --only <root-module> --max-module-depth 2

it worked well for me ๐Ÿ˜ƒ

Thanks, @Hugo-C, I believe I had the same question/problem as the OP, and your suggestion did exactly what I wanted!

I found it not clear that this was possible by reading the docs, so maybe a teensy edit would be helpful. ๐Ÿค”

@sheromon , @Hugo-C , @RobbinDG if any of you want to make a docs PR, I'll be happy to merge it...

It was harder than I expected to find a Python package that had more than two levels of depth to use as an example, since pydeps itself has only two levels, and reducing it to one level is silly. Is it okay to use another open-source Python package for an example? pandas has more than two levels...