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

[UI] Add ability to view query plans directly in the UI #301

Merged
merged 10 commits into from
Oct 2, 2022

Conversation

onthebridgetonowhere
Copy link
Contributor

@onthebridgetonowhere onthebridgetonowhere commented Oct 1, 2022

Add support for viewing the graph in the browser.

Which issue does this PR close?

Closes #275 .

Rationale for this change

Explained in the issue linked above.

What changes are included in this PR?

Adds the possibility of viewing the diagram generated from the DOT file

Are there any user-facing changes?

Yes, another button is added in the UI's scheduler actions list

… the moment, as calling the d3.graphviz function fails due to the selector not being able to fetch the right node.
@andygrove
Copy link
Member

Thanks @onthebridgetonowhere! I will take a look this weekend and see if I can help.

@andygrove
Copy link
Member

@andygrove
Copy link
Member

I tried this:

  var graphDiv = useRef<HTMLDivElement | null>(null);

  useEffect(() => {
    if (isOpen) {
      dot();
      if (graphDiv.current != null) {
        d3.graphviz(graphDiv.current).renderDot(dot_data);
      }
    }
  }, [graphDiv.current]);

  return (
    <>
      <Button onClick={onOpen}>View Graph</Button>
      <Modal isOpen={isOpen} onClose={onClose}>
        <ModalOverlay />
        <ModalContent>
          <ModalHeader>Graph for {props.value} job</ModalHeader>
          <ModalCloseButton />
          <ModalBody>
            <div ref={node => graphDiv.current = node}></div>
          </ModalBody>
          <ModalFooter>
            <Button colorScheme="blue" mr={3} onClick={onClose}>
              Close
            </Button>
          </ModalFooter>
        </ModalContent>
      </Modal>
    </>
  );

This seemed to get farther but then failed with a wasm validation error - failed to match magic number.

@onthebridgetonowhere
Copy link
Contributor Author

onthebridgetonowhere commented Oct 2, 2022

I made it work! 🎆 I found the wasm error to be hard to grasp and hard to find understandable solutions. I went a different route by having a new backend API and rendering the SVG by reusing a React component.

There are a few tradeoffs though, which we need to consider:

  • a new API that creates an SVG from the DOT string
  • the new API requires a new crate, the graphviz-rust crate
  • a new React dependency that allows us to easily render the SVG (react-inlinesvg)
  • the backend does the conversion; I do not know of the performance of the graphviz-rust crate. I suggest we experiment with it, and optimize later if needed.

@andygrove let me know what you think, and thanks for your previous help.

image

image

@onthebridgetonowhere onthebridgetonowhere marked this pull request as ready for review October 2, 2022 05:26
@andygrove andygrove changed the title Add support for viewing the graph in the browser. It does not work at… [UI] Add ability to view query plans directly in the UI Oct 2, 2022
Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

This is fantastic! I just tested this out locally. Thanks @onthebridgetonowhere

@andygrove andygrove merged commit 2ae2d51 into apache:master Oct 2, 2022
@onthebridgetonowhere onthebridgetonowhere deleted the add_graph_view_to_ui branch October 2, 2022 18:46
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.

[UI] Add ability to render query plans
2 participants