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

🪓 Split Output into OutputsOutput[] #1671

Closed
wants to merge 26 commits into from

Conversation

agoose77
Copy link
Contributor

@agoose77 agoose77 commented Nov 22, 2024

This PR closes #1674 by introducing two new versions (1* and 2) of the MyST AST:

Version 2

type CodeBlock = {
  type: "block";
  kind: "notebook-code",
  children: [
    Code,
    Outputs
  ]
}

type Outputs = {
  type: "outputs";
  children: Output[];
  visibility?: ...;
  identifier?: ...;
  html_id?: ...;
  label?: ...;
}

type Output = {
  type: "output";
  children: GenericNode[];
  jupyter_data: IOutput;
  identifier?: ...;
  html_id?: ...;
  label?: ...;
}

Version 1*

type CodeBlock = {
  type: "block";
  kind: "notebook-code",
  children: [
    Code,
    Output
  ]
}
type Output = {
  type: "output";
  children: GenericNode[];
  data: IOutput[];
  _future_ast: Outputs
}

This PR does the following things with these AST types:

  1. Recognise version 1* and 2 in input data (e.g. .myst.json or XRefs) and upgrade it to version 2
  2. Process MyST AST in version 2
  3. Export MyST AST to disk as version 1* (to avoid breaking old consumers)

The idea here is to start publishing a modified version of the current schema that is forward-compatible (version 1*) ASAP. Then, at some future moment, we will trigger an AST upgrade and start publishing version 2 in a future build of MyST.

Versions of mystmd that include #1671 will recognise this AST, and have no problems in handling it.

Warning

Upgrading from 1 to 2 is a lossy process — there is no obvious way to figure out which output.children belong to which output.data iff. the output.data.length > 1. I think that's a rare case. If we really care about it, we can look to store the original version 1 AST to support round-tripping.

This PR does not yet solve #1734 entirely -- for that, we need to pull in the myst-compat package more dynamically, so that it can be pulled in for old mystmd binaries.

To Do

  • Validate behavior of reduceOutputs -- do we want this removing Outputs nodes?
  • Validate change to blockMetadataTransform that leaves empty Outputs nodes
  • Apply block data labelling after execution (follow up)
  • Investigate consequences of parsing Markdown & images etc. before making a release

Copy link

changeset-bot bot commented Nov 22, 2024

🦋 Changeset detected

Latest commit: 90ac03d

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

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

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 4 times, most recently from e278262 to 1f3a8c2 Compare November 25, 2024 11:50
@agoose77 agoose77 changed the title ⬆️🤫 Lift and parse Markdown/text outputs from Jupyter outputs (option 2) ⬆️🤫 Split Output into Outputs -> Output[] Nov 25, 2024
@agoose77 agoose77 changed the title ⬆️🤫 Split Output into Outputs -> Output[] 🪓 Split Output into Outputs -> Output[] Nov 25, 2024
@agoose77 agoose77 force-pushed the agoose77/feat-future-ast-outputs branch from 1f3a8c2 to 48e8edd Compare January 14, 2025 14:06
@agoose77 agoose77 force-pushed the agoose77/feat-future-ast-outputs branch from 48e8edd to b257932 Compare January 14, 2025 14:14
@agoose77 agoose77 marked this pull request as ready for review January 16, 2025 13:05
@agoose77 agoose77 marked this pull request as draft January 16, 2025 13:08
@agoose77 agoose77 changed the title 🪓 Split Output into Outputs -> Output[] 🪓 Split Output into OutputsOutput[] Jan 16, 2025
@agoose77 agoose77 marked this pull request as ready for review January 16, 2025 16:34
@agoose77 agoose77 marked this pull request as draft January 16, 2025 16:46
@rowanc1
Copy link
Member

rowanc1 commented Jan 22, 2025

From meeting:

  • Split out the compat repo.
  • Make it simple, e.g. footnote number --> enumerated (currently)
  • merge that!
  • Open an outputs pr on top (only focus on breaking changes, no _futureAst)
  • Make that at the same time for a theme PR. We release those at the same time.
  • Them do the markdown from outputs PR.

@agoose77
Copy link
Contributor Author

Closing this in favour of a rework as a simple package

@agoose77 agoose77 closed this Jan 23, 2025
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.

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