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

DM-46503: Implement Mermaid for pipeline and quantum graph visualization #459

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

enourbakhsh
Copy link
Contributor

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 49.40120% with 169 lines in your changes missing coverage. Please review.

Project coverage is 82.32%. Comparing base (9865311) to head (61f3361).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...pipe/base/pipeline_graph/visualization/_mermaid.py 20.17% 91 Missing ⚠️
python/lsst/pipe/base/mermaid_tools.py 51.25% 63 Missing and 15 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #459      +/-   ##
==========================================
- Coverage   83.20%   82.32%   -0.89%     
==========================================
  Files         103      106       +3     
  Lines       12227    12561     +334     
  Branches     1546     1609      +63     
==========================================
+ Hits        10174    10341     +167     
- Misses       1642     1795     +153     
- Partials      411      425      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@enourbakhsh enourbakhsh changed the title DM-46503: Implement Mermaid for pipeline graph visualization DM-46503: Implement Mermaid for pipeline and quantum graph visualization Dec 18, 2024

Parameters
----------
qgraph : `lsst.pipe.base.QuantumGraph`
Copy link
Contributor

Choose a reason for hiding this comment

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

To help with readability in the built docs, you could prefix this with a ~:

qgraph : `~lsst.pipe.base.QuantumGraph`

close = True

# Start Mermaid code block and flowchart.
print("```mermaid", file=file)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not part of mermaid, right? This is a markdown wrapper around mermaid, to allow mermaid to be parsed in a markdown file? This may break things for other users who are using another tool to convert mermaid into a PNG/SVG/PDF/etc, and so should probably be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, we don't really need that. Removed it!

print(f"{taskNodeName} --> {dsNode}", file=file)

# End Mermaid code block.
print("```", file=file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here, this is markdown syntax, not mermaid syntax, if I understand mermaid correctly?

"""Format and sort dimension names as a comma-separated list inside curly
braces.

For example, if dims=["detector", "visit"], returns "{detector,visit}".
Copy link
Contributor

Choose a reason for hiding this comment

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

returns "{detector, visit}".

if not dims:
return ""
sorted_dims = sorted(dims)
return "{" + ", ".join(sorted_dims) + "}"
Copy link
Contributor

Choose a reason for hiding this comment

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

If you changed this to:

return "{" + ", ".join(sorted_dims) + "}"

I think it would prevent line breaks across dimensions, which would aid in readability and more closely mimic the existing DOT outputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


# If storage class is available and requested, display it.
if show_storage and getattr(connection, "storageClass", None) is not None:
lines.append(f"<i>storage class:</i>&nbsp;{html.escape(str(connection.storageClass))}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a &nbsp; between storage and class would also help prevent line breaks here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

close = True

# Begin the Mermaid code block with top-down layout.
print("```mermaid", file=file)
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, I think this is markdown syntax, rather than something in the mermaid schema. Is that correct?

print(f"linkStyle {prereq_str} stroke-dasharray:5;", file=file)

# End code block
print("```", file=file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also potential markdown syntax.

xgraph, options = parse_display_args(pipeline_graph, **kwargs)

# Begin the Mermaid code block.
print("```mermaid", file=stream)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also potential markdown syntax.

print(f"linkStyle {','.join(prereq_indices)} stroke-dasharray:5;", file=stream)

# End code block.
print("```", file=stream)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also potential markdown syntax.

Copy link
Contributor

@leeskelvin leeskelvin left a comment

Choose a reason for hiding this comment

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

LGTM! A few formatting suggestions which I hope are useful. Nicely done!

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

Successfully merging this pull request may close these issues.

2 participants