Skip to content

🤖 Store execution outputs in Outputs #1903

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

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

Conversation

agoose77
Copy link
Contributor

@agoose77 agoose77 commented Mar 7, 2025

This PR closes #1674 by changing our internal representation of cell outputs so that they are children of the Outputs node.

Note

Part of initiative #1026

Notable Changes

  • Address individual output children with labels ${block.identifier}-outputs-${N}
  • Add new parent outputs node with identifier ${block.identifier}-outputs

Tasks

  • Check that .docx exports still export matplotlib figures
  • Check that outputs can still be embedded
  • Check that individual output nodes can be embedded
  • Check that individual outputs are still minified
  • Check that JATS exports still export matplotlib figures

Copy link

changeset-bot bot commented Mar 7, 2025

🦋 Changeset detected

Latest commit: fccf681

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
mystmd Minor
myst-directives Patch
myst-transforms Patch
myst-spec-ext Patch
myst-execute Patch
myst-cli Minor
myst-common Patch
myst-config Patch
myst-frontmatter Patch
myst-parser Patch
myst-roles Patch
myst-to-html Patch
myst-migrate Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@agoose77 agoose77 force-pushed the agoose77/feat-future-ast-outputs branch 3 times, most recently from cec055e to 6870f57 Compare March 7, 2025 11:05
Copy link
Member

@rowanc1 rowanc1 left a comment

Choose a reason for hiding this comment

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

A few comments as I am looking now.

@rowanc1
Copy link
Member

rowanc1 commented Mar 7, 2025

Thoughts on a testing plan for this:

  • thebe can attach to the right place, there are likely going to be changes in the theme due to this
  • contents are still minified and downloaded correctly (e.g. images are a network request, etc.)
  • docx, typst, latex, JATS still export matplotlib images and latex
  • mystmd docs work for the embed and interactive components
  • bokeh example, holoviews, plotly, sympy
  • placeholders work

const outputsNode = select('outputs', block) as GenericNode | undefined;
if (outputsNode !== undefined && !outputsNode.identifier) {
// Label outputs node
outputsNode.identifier = `${block.identifier}-output`;
Copy link
Member

Choose a reason for hiding this comment

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

I think that these ID changes may need to be taken into account in the upgrade/downgrade script for thebe to continue working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's keep an eye on that

@@ -270,12 +273,14 @@ describe('propagateBlockDataToCode', () => {
result = mdast.children[0].children[0].visibility;
break;
case 'output':
if (!has_output && target == 'output') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

target is known to be output here.

@agoose77 agoose77 force-pushed the agoose77/feat-future-ast-outputs branch from 2060521 to 5857844 Compare April 1, 2025 10:20
@agoose77 agoose77 marked this pull request as ready for review April 2, 2025 10:36
@agoose77 agoose77 changed the title 🤖 Store execution outputs in Outputs [[⚠️ Do Not Merge ⚠️]] 🤖 Store execution outputs in Outputs Apr 2, 2025
@agoose77 agoose77 force-pushed the agoose77/feat-future-ast-outputs branch from 826b957 to 455e0d8 Compare April 2, 2025 12:49
@agoose77 agoose77 changed the title [[⚠️ Do Not Merge ⚠️]] 🤖 Store execution outputs in Outputs ⚠️ DO NOT MERGE ⚠️ 🤖 Store execution outputs in Outputs Apr 3, 2025
@agoose77 agoose77 changed the title ⚠️ DO NOT MERGE ⚠️ 🤖 Store execution outputs in Outputs ⚠️ DO NOT MERGE ⚠️ — 🤖 Store execution outputs in Outputs Apr 10, 2025
@agoose77 agoose77 added the blocked Waiting for another task to be compled label May 23, 2025
const output = {
type: 'output',
const outputs = {
type: 'outputs',
id: nanoid(),
Copy link
Contributor

Choose a reason for hiding this comment

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

@agoose77 adding this immediately enables compute in figures & embeds in many of the test cases. If there is a place in myst-execute where this should be added I suggest we do. If you could please do that, or if it's trivial, point me to the line to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, not quite following - are you saying that it's broken currently?

Copy link
Contributor

@stevejpurves stevejpurves Jun 25, 2025

Choose a reason for hiding this comment

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

We need this change here for in-browser compute.

On this PR jupyter-book/myst-theme#571 you mentioned that myst-execute does not add the id, so I'm just flagging that we need one. Adding the id here seems to be enough, but if there is a further change needed in myst-execute, in line with your comment that should also be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm in a conference atm. I need to check the status quo — that comment is about output.id not outputs.id. I think the intention is that the id remainsper-outputs, somyst-executeshould still work (it preserves the fields of theoutputsnode, and theid` is pre-populated).

IIRC myst-theme in that PR now accesses the outputs.id via context, so that the output renderer has access to it.

@stevejpurves stevejpurves added enhancement New feature or request and removed blocked Waiting for another task to be compled labels Jun 26, 2025
@stevejpurves
Copy link
Contributor

stevejpurves commented Jun 26, 2025

Great - @agoose77 I think this is good to go pending test fixes, and is working against the theme PR jupyter-book/myst-theme#571

but I also note the testing points from @rowanc1 above:

  • docx, typst, latex, JATS still export matplotlib images and latex
  • mystmd docs work for the embed and interactive components

The second will work after th content there is updated to the new form as the PR above confirms external emdbedding and referencing works as before.

@agoose77 agoose77 force-pushed the agoose77/feat-future-ast-outputs branch from 76c5b6b to fccf681 Compare July 2, 2025 12:01
@agoose77 agoose77 changed the title ⚠️ DO NOT MERGE ⚠️ — 🤖 Store execution outputs in Outputs 🤖 Store execution outputs in Outputs Jul 2, 2025
Copy link
Contributor

@stevejpurves stevejpurves left a comment

Choose a reason for hiding this comment

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

@agoose77 verified the hard copy output, which was the last ask on this PR. I think this is good to go.

@rowanc1
Copy link
Member

rowanc1 commented Jul 7, 2025

Before merging, we should ensure that the date in the v3 transformation is fixed to the release date (or closer to it). And that we bump the content version of the spec to v3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for representing per-output sub-ASTs in MyST AST
3 participants