Coder Social home page Coder Social logo

felidz / carport Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 782 KB

Dependency Graph from Python imports

Home Page: https://felidz.github.io/carport/

License: Apache License 2.0

Python 1.91% Jupyter Notebook 97.76% SCSS 0.04% CSS 0.29%
dependency-graph import-graph import-map python

carport's Introduction

Carport

Dependency Graph from Python imports (CARPORT).

PyPI Version GitHub License

GitHub commit activity GitHub code size in bytes GitHub top language

GitHub last commit GitHub Actions CI Workflow Status GitHub Actions Docs Workflow Status

Installation

pip install carport

Usage

from carport.core import ImportGraph

depg = ImportGraph(root = '..', project='carport')
# vars(depg)
# specify irrelevant modules
ignore_nodes = ['io', 'IPython', 'pprint', 'subprocess']
# export to dot string
dot = depg.to_dot(ignore_nodes=ignore_nodes)
display(dot)
'digraph  {\n"carport.vis";\n"carport.core";\nnetworkx;\npathlib;\nast;\nkroki;\ngraphviz;\n"carport.vis" -> "carport.core"  [key=0];\nnetworkx -> "carport.core"  [key=0];\npathlib -> "carport.core"  [key=0];\nast -> "carport.core"  [key=0];\nkroki -> "carport.vis"  [key=0];\ngraphviz -> "carport.vis"  [key=0];\n}\n'
# draw graph with graphviz
dotg = depg.draw_dot(ignore_nodes=ignore_nodes)
display(dotg)

# export to d2 string
d2 = depg.to_d2(ignore_nodes=ignore_nodes)
display(d2)
'\n        vars: { \n            d2-config: { \n                layout-engine: elk \n                } \n            }\n        direction: right\n        **.style.border-radius: 99\n        *.style.font: mono\n        \npathlib -> carport.core\ngraphviz -> carport.vis\nsubprocess -> carport.vis\nast -> carport.core\ncarport.vis -> carport.core\nkroki -> carport.vis\nnetworkx -> carport.core\nio -> carport.core\nIPython -> carport.vis\nio: null\nIPython: null\npprint: null\nsubprocess: null'
# draw graph with d2 or kroki
d2g = depg.draw_d2(ignore_nodes=ignore_nodes, app='d2')
display(d2g)

# for large graphs, you can use gravis
#! pip install gravis

import networkx as nx 
import gravis as gv

g = depg.to_nx(ignore_nodes=ignore_nodes)
layout = nx.circular_layout(g, scale=4*len(g)**1.05)
for node_id, (x, y) in layout.items():
    node = g.nodes[node_id]
    node['x'], node['y'] = x, y
gv.d3(g, edge_curvature=1, node_hover_neighborhood = True, use_edge_size_normalization=True)

TODOs:

[] imports concerning __init__.py

[] py_d2 to d2 (like graphviz to graphviz)

Related

import-deps: Github

pydeps: Github

snakefood3: Github

kroki: online editor, python-interface

D2: doc, online editor, python-interface

Statistics

GitHub Repo stars PyPI - Downloads

Copyright

Copyright © 2024 onward Felidz. All rights reserved, with certain parts of the project specifically licensed and subject to different terms and conditions, e.g., source code of the project under the Apache-2.0 license; you may not use this project except in compliance with the license.

Citation

BibTeX citation:

@misc{felidz2024,
  author = {Felidz},
  title = {Carport},
  year = {2024},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/felidz/carport}}
}

carport's People

Contributors

felidz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.