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

Support earlier notebook versions #13

Merged
merged 6 commits into from
Feb 26, 2024
Merged

Support earlier notebook versions #13

merged 6 commits into from
Feb 26, 2024

Conversation

bevzzz
Copy link
Owner

@bevzzz bevzzz commented Feb 24, 2024

This PR adds decoders for Jupyter Notebooks v4.*, v3.0, v2.0, and v1.0.

It turns out v1 and v2 are not different from v3 in any way that affects the rendering, so the same decoder can be reused for all notebooks in the three formats.

BREAKING : decode.Decoder requires an additional method, so the existing implementations had to be updated.

Decoder for v4.4 is reused for all notebooks with major version 4, because they
their differences do not affect how the notebooks are rendered:
- v4.5 requires that each cell has a unique ID
- versions < v4.3 do not have the 'code_cell.metadata.execution' field, which holds the code's execution time.
  They also do not have 'raw_cell.metadata.jupyterf.source_hidden' which controls if the source is hidden.
  This has a default behaviour in 'nb' and is probably not that important anyways.
  Finally, they miss metadata.title field, which is currently not used also in v4.4 notebooks.
Prior to v4.0:
- top-level 'worksheets' contained multiple worksheets with the actual 'cells'
- execution_results was called pyout
- error output was called pyerr
- code cell 'source' was called 'input'; execution_count was called prompt_number
- mime-bundle explicitly defined keys for all mime-tyipes which it supported and
had to be decoded differently

BREAKING: decode.Decoder interface not inlcudes ExtractCells method to handle the
deprecation of top-level 'worksheets'
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 81.86%. Comparing base (40a335d) to head (230f0ff).
Report is 1 commits behind head on main.

Files Patch % Lines
decode/decode.go 50.00% 2 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
+ Coverage   81.56%   81.86%   +0.30%     
==========================================
  Files          11       11              
  Lines         575      579       +4     
==========================================
+ Hits          469      474       +5     
+ Misses         85       83       -2     
- Partials       21       22       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Turns out, v1 and v2 only differ in how Jupyter interprets them,
not in the schema itself. We can use the same decoder we use
for v3.
This has no logic implications, but it feels like multiple instances are unnecessary
@bevzzz bevzzz merged commit 7525745 into main Feb 26, 2024
1 check passed
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.

2 participants