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

Mermaid rendering on RTD is brittle #3395

Closed
astrojuanlu opened this issue Dec 6, 2023 · 10 comments
Closed

Mermaid rendering on RTD is brittle #3395

astrojuanlu opened this issue Dec 6, 2023 · 10 comments
Labels
Component: DevOps Issue/PR that addresses automation, CI, GitHub setup Issue: Bug Report 🐞 Bug that needs to be fixed

Comments

@astrojuanlu
Copy link
Member

Recently I've been spotting some intermittent failures caused by the Mermaid rendering:

WARNING: mermaid code 'flowchart TD\n  A[Start] --> B{Do you prefer developing your projects in notebooks?}\n  B -->|Yes| C[Use a Databricks workspace to develop a Kedro project]\n  B -->|No| D{Are you a beginner with Kedro?}\n  D -->|Yes| E[Use an IDE, dbx and Databricks Repos to develop a Kedro project]\n  D -->|No| F{Do you have advanced project requirements<br>e.g. CI/CD, scheduling, production-ready, complex pipelines, etc.?}\n  F -->|Yes| G{Is rapid development needed for your project needs?}\n  F -->|No| H[Use an IDE, dbx and Databricks Repos to develop a Kedro project]\n  G -->|Yes| I[Use an IDE, dbx and Databricks Repos to develop a Kedro project]\n  G -->|No| J[Use a Databricks job to deploy a Kedro project]': Mermaid exited with error:
[stderr]
b'\nTimeoutError: Timed out after 30000 ms while waiting for the WS endpoint URL to appear in stdout!\n    at ChromeLauncher.launch (file:///home/docs/.asdf/installs/nodejs/19.0.1/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:119:23)\n    at async run (file:///home/docs/.asdf/installs/nodejs/19.0.1/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:404:19)\n    at async cli (file:///home/docs/.asdf/installs/nodejs/19.0.1/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:184:3)\n\n'
[stdout]
b''

https://readthedocs.org/projects/kedro/builds/22757197/

@astrojuanlu astrojuanlu added Issue: Bug Report 🐞 Bug that needs to be fixed Component: DevOps Issue/PR that addresses automation, CI, GitHub setup labels Dec 6, 2023
@astrojuanlu
Copy link
Member Author

Looks like the pupetteer version pinned by mermaid-cli is quite old mermaid-js/mermaid-cli#627

@astrojuanlu
Copy link
Member Author

Upstream issue puppeteer/puppeteer#10556

Ways we can try to fix this:

  • Upgrade puppeteer
  • Use Firefox engine
  • Set timeout to 0

We'd need a package.json for this mermaid-js/mermaid-cli#627 (comment)

@astrojuanlu
Copy link
Member Author

Or commit a pre-rendered PNG to the source tree and remind ourselves to re-render it when the source changes (which doesn't happen that often??)

@stichbury
Copy link
Contributor

I like that option TBH have never been a big fan of using Mermaid to build dynamic graphics when a PNG will do.

@stichbury
Copy link
Contributor

I want to make some changes to the docs that use the mermaid graphic anyway so will factor in a change to the graphics at the same time.

@astrojuanlu
Copy link
Member Author

sphinxcontrib-mermaid doesn't seem to support static pre-rendering mgaitan/sphinxcontrib-mermaid#134

@stichbury
Copy link
Contributor

@astrojuanlu
Copy link
Member Author

Yeah we can actually take the output from build/html and paste it in our images directory. There is a number of workarounds, but it looks like we'd lose the convenience of having the Mermaid code there.

@stichbury
Copy link
Contributor

stichbury commented Dec 20, 2023

We can put it in a comment though, right?

@astrojuanlu
Copy link
Member Author

That's where my mind was right now...

Essentially we can call mermaid-cli ourselves once with these parameters, store the PNG under version control, and have the Mermaid code as a comment next to the diagram itself.

mermaid_params = ["-p", here / "puppeteer-config.json", "-s", "2"]

I'll send a PR with this.

astrojuanlu added a commit that referenced this issue Dec 20, 2023
Fix gh-3395.

Signed-off-by: Juan Luis Cano Rodríguez <juan_luis_cano@mckinsey.com>
astrojuanlu added a commit that referenced this issue Dec 20, 2023
Fix gh-3395.

Signed-off-by: Juan Luis Cano Rodríguez <juan_luis_cano@mckinsey.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: DevOps Issue/PR that addresses automation, CI, GitHub setup Issue: Bug Report 🐞 Bug that needs to be fixed
Projects
Archived in project
Development

No branches or pull requests

2 participants