stateful / runme

DevOps Workflows Built with Markdown
https://runme.dev
Apache License 2.0
901 stars 30 forks source link

Question: How to render cell output using Data Table Renderers #619

Closed jlewi closed 1 week ago

jlewi commented 1 week ago

Here's a discord thread with a demo of using Data Table Renderers to render JSON output as a table.

It looks like the steps are

  1. Install the Data Table Renderers Extension
  2. Change the cell output mime/type to be application/json
  3. Change the cell presentation type to be data table renderer

When I click on change cell presentation I don't see the data table renderer option. Do you know what I'm doing wrong?

https://github.com/stateful/runme/assets/777219/5cfeae5a-4572-474d-aff5-7d3748dd074a

sourishkrout commented 1 week ago

In the Configure foldout for the respective cell, please untick interactive as per https://docs.runme.dev/configuration/cell-level#human-friendly-output.

Interactive here means "attach a tty/terminal." Do you have any suggestions on how we can make this clearer in docs or otherwise?

Btw, you should be able to leave the mimeType empty since Runme has a pretty accurate auto-detection of JSON, CSV, etc now.

sourishkrout commented 1 week ago

I just checked how mime/media type detection works and realized we could technically offer a button (e.g., next to "Copy") to switch to non-interactive mode if we detect a non-plain-text media type 🤔. We could track this as a feature request. It likely would make it more "obvious" how to leverage other renderers. Thoughts, @jlewi?

jlewi commented 1 week ago

Thank you. Regarding the docs; I never thought to look at https://docs.runme.dev/configuration/cell-level#human-friendly-output.

I wound up here https://marketplace.visualstudio.com/items?itemName=RandomFractalsInc.vscode-data-table Which didn't mention it.

For the docs it might be helpful to have guide sections that show how to deal with rendering e.g. in this case "How to work with JSON" or perhaps even higher level "How to work with BigQuery"

It looks like you have a bunch of how tos under the guide section but based on the titles none of them jump out to me as relevant to my problem in this case.

sourishkrout commented 1 week ago

Thanks for the feedback! We'll take the suggestions for the docs back to the team.

jlewi commented 1 week ago

I haven't been able to reproduce this consistently but in some cases it looks like I observed it being necessary to clear cell outputs and rerun the cell after disabling interactive mode. I think the steps were

  1. Create a cell with bq --format=json...
  2. Execute it
  3. Change cell to disable interactive
  4. Try to change cell; other formats don't show up
  5. Rerun cell
  6. Try to change presentation; other formats don't show up
  7. Clear cell outputs
  8. Rerun the cell
  9. Cell is now displayed correctly

A confounding factor is that it looks like the bq query will sometimes output job stats information to stderr if the job takes a long time. I think this prevents the output from being valid JSON. Redirecting to "2>/dev/null" seems to fix that problem.