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

docs: add dynamic entity-relationship diagram to docs #28130

Merged
merged 17 commits into from
Apr 23, 2024
Merged

Conversation

mistercrunch
Copy link
Member

@mistercrunch mistercrunch commented Apr 18, 2024

Screenshot 2024-04-18 at 11 38 26 AM

Recently I stumbled upon plantuml and its ability to render entity relationship diagrams (and other various UML) defined as code. Originally started as a PoC one-off, but it's looking pretty good and could be added to our doc builds.

I wanted to visualize the ERD, and thought it'd be a great asset for contributors to be able to refer to it.

In this PR:

  • I wrote a script that introspects the models in Superset
    and use jinja2 to render a erd.plantuml, and a erd.svg
  • Adding a interactive (zoom/pan) browser to browse the svg.

Looking for input as to whether we want this in the repo / docs.

@github-actions github-actions bot added the doc Namespace | Anything related to documentation label Apr 18, 2024
@rusackas
Copy link
Member

You'll have to add an exception (and comment) in the Depndendy Review yaml file that states we're using this under the BSD license, which I think is Apache 2.0 compatible.

@github-actions github-actions bot added the github_actions Pull requests that update GitHub Actions code label Apr 22, 2024
@mistercrunch mistercrunch marked this pull request as ready for review April 23, 2024 19:03
@@ -39,6 +39,10 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Setup Python
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

planning on YOLO this script as it runs on master merges

- 'pkg:npm/applitools/tunnel-client'
- 'pkg:npm/applitools/utils'
# Selecting BSD-3-Clause licensing terms for node-forge to ensure compatibility with Apache
- 'pkg:npm/[email protected]'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup!

.rat-excludes Outdated
@@ -66,3 +66,8 @@ google-big-query.svg
google-sheets.svg
postgresql.svg
snowflake.svg

# docs-related
docs/docs/.htaccess*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem like we should need this line... wondering what might've changed here.

# docs-related
docs/docs/.htaccess*
erd.plantuml
erd.svg
Copy link
Member

@rusackas rusackas Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably add the license boilerplate to the SVG as part of the action, if it makes sense to do so.

scripts/erd.py Outdated

# Load the template
template = env.get_template("erd.plantuml.template")
rendered = template.render(data=data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe splice in the ASF license boilerplate here?

scripts/templates/erd.plantuml.template Show resolved Hide resolved
for model in db.Model.registry.mappers:
group_name = (
TABLE_TO_GROUP_MAP.get(model.mapper.persist_selectable.name)
or "Other Models"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be "other" (a bit of a junk drawer) or "Uncategorized Models" implying tech debt to be swept up?

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems generally good to me, with the caveat that we might want to avoid rat exclusions if possible. Also wondering if there's a way to build the diagram only if files with models/migrations change. But these are optimizations, not blockers.

@mistercrunch mistercrunch merged commit 9db431b into master Apr 23, 2024
28 checks passed
@rusackas rusackas deleted the plantuml branch April 24, 2024 00:00
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.1.0 labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels doc Namespace | Anything related to documentation github_actions Pull requests that update GitHub Actions code size/XXL 🚢 4.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants