Skip to main content

Visualize your dependencies with Graph My Repo

· 5 min read
Benjy Weinberger

GraphMyRepo.com in action, graphing the dependencies and code structure of pantsbuild/pants. Source: Toolchain.com

To make it easier to understand the value and power of dependency inference, Toolchain (the lead sponsor of Pants) has built a new site: Graph My Repo. As its name suggests, Graph My Repo shows you an interactive graph of a public GitHub repo of your choice…

info

Pants automatically analyzes your code's structure and dependencies and uses this data to speed up your builds. Toolchain has built a site that lets you harness this power by creating an interactive visual code graph of a public repository.

One of the most exciting features of Pants v2 is dependency inference: Pants uses static analysis and smart heuristics to automatically model and analyze the structure of your codebase, without you having to write thousands of lines of metadata.

Dependency inference makes Pants powerful because it allows Pants to automatically understand fine-grained internal and external dependencies for every source file in your repo. In the vast majority of cases, it can do that with no manual metadata at all. Pants uses that knowledge to conserve resources and speed up your build and deploy cycles.

Some important Pants features that use granular data from dependency inference are:

  • Fine-grained invalidation When a source file changes, Pants can compute the minimal amount of incremental work necessary to keep the build up to date, rather than having to conservatively rerun a huge amount of build work.
  • Fine-grained caching Unlike standard CI caches, which are typically an all-or-nothing proposition for build outputs, Pants can use dependency data to compute very precise cache keys, so that data unaffected by changes retain the same cache key.
  • Fine-grained concurrency When Pants knows that two source files are independent, it can safely operate on them concurrently.
  • Selective deploys Pants helps you understand which artifacts are affected by a set of changes, which allows you to confidently only redeploy the ones affected by changes since your last deploy.

Earlier build systems either ignore fine-grained structure entirely (Ant, Maven, Gradle, SBT) or require you to laboriously provide and maintain that information as external metadata (Make, Pants v1, Please, Buck, Bazel). With Pants, you don't have to update explicit dependency information in BUILD files whenever you edit and refactor your code. As recently demonstrated by a team at IBM, this avoids a major pain point experienced by users of other build systems.

Instantly visualize the power of dependency inference, with your favorite repos

To make it easier to understand the value and power of dependency inference, Toolchain (the lead sponsor of Pants) has built a new site: Graph My Repo. As its name suggests, Graph My Repo shows you an interactive graph of a public GitHub repo of your choice.

To use Graph My Repo, point it at a repo on GitHub (in this initial release, the site supports Python, Go, Java, and Scala-based repositories). Pants will automatically clone the repo, set itself up, and run the dependency inference logic.

After a few minutes, the interactive graph will be ready. You can browse the graph and expand or collapse nodes to drill down into finer detail. All the dependency and structure data is generated with no human intervention at all.

Every repo is also cached so you can quickly return to the graph on future visits. We've already got graphs prepared for Pants itself, Django, and Sentry – check them out!

Visualizing your dependency structure is a powerful benefit of Pants' automatic dependency inference. Pants users at companies like IBM, Astranis, iManage, and others have described how dependency inference lends crucial insights that impact code quality. For instance:

"Pants has helped us gain better insight into our repository by being able to easily scan for and report the transitive dependencies of modules. Having that insight has helped us plan out how to minimize the coupling of our modules." —Nathanael England, Astranis Space Technologies Corp

Graph My Repo makes such insights easy to access for those who aren't yet using Pants. If you find this tool useful, please share it with like-minded people — and consider exploring the many additional benefits Pants can offer your team!

Toolchain would love to get your feedback on GraphMyRepo. If you're interested in its functionality for your private repo, let Toolchain know, as the team is currently working on offering it as a feature alongside BuildSense, the company's Pants-based build insights dashboard.

And, of course, please join us at the friendly Pants community Slack, where you can learn more about Pants from users and contributors, and find out how Pants can give you fast, stable builds with easy setup and maintenance.


✏️About the Author

Benjy Weinberger is the co-creator of Pants, and a longtime maintainer of the open source project. He and Pants co-creator John Sirois founded Toolchain, the lead sponsor of Pants, to provide commercial products and services that extend Pants.