Skip to content

Add a brief guide to choosing between .md and .ipynb#1969

Merged
agoose77 merged 3 commits into
mainfrom
md-ipynb-guidance
Apr 17, 2025
Merged

Add a brief guide to choosing between .md and .ipynb#1969
agoose77 merged 3 commits into
mainfrom
md-ipynb-guidance

Conversation

@choldgraf
Copy link
Copy Markdown
Collaborator

This is a brief guide to give users an idea for when to choose between markdown-based notebooks and ipynb files. It's inspired by a conversation with @bsipocz in this discussion thread. The goal of this page isn't to tell users what to do, but to help them understand the pros/cons of each approach, and when they should consider using each format.

@bsipocz if you have any thoughts (recognizing that we can't be too opinionated here, I'd rather give information than tell people they're "doing it wrong") on how we can make this content more useful, please provide suggestions!

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 16, 2025

⚠️ No Changeset found

Latest commit: 921cc77

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@choldgraf choldgraf changed the title Add a brief guide to choosing between and Add a brief guide to choosing between .md and .ipynb Apr 16, 2025
@bsipocz
Copy link
Copy Markdown
Contributor

bsipocz commented Apr 16, 2025

@bsipocz if you have any thoughts (recognizing that we can't be too opinionated here, I'd rather give information than tell people they're "doing it wrong") on how we can make this content more useful, please provide suggestions!

Thanks! It's a good document, but doesn't fully address my use case and needs, where us tutorial repo maintainers decided on markdown (exactly for the pros listed here), but then the user comes panicking and starts a debate that they don't want to use markdown.

Copy link
Copy Markdown
Contributor

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Thanks @choldgraf!

Comment thread docs/md-vs-ipynb.md
@@ -0,0 +1,31 @@
# How to choose between `.ipynb` and `.md` when writing Jupyter notebooks

You can work with Jupyter notebooks in both the `.ipynb` format as well as in a text-based format like [MyST Markdown](./notebooks-with-markdown.md). This is a brief guide to help you choose when to use one vs. the other.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe add one more sentence that working in jupyper/jupyterlab the user experience will be the same, they don't usually notice the difference between the formats assuming the required dependencies, jupytext and maybe jupyerlab-myst, are installed.

Comment thread docs/md-vs-ipynb.md Outdated
Comment thread docs/md-vs-ipynb.md Outdated
@choldgraf
Copy link
Copy Markdown
Collaborator Author

What's the main thing we are missing here @bsipocz ? Could you suggest one or two "section headers" and I can try to flesh it out with content?

choldgraf and others added 2 commits April 16, 2025 18:06
Co-authored-by: Brigitta Sipőcz <b.sipocz@gmail.com>
@choldgraf
Copy link
Copy Markdown
Collaborator Author

@bsipocz I added an extra section about reading/writing the two formats. I think that addresses your question. What do you think?

Comment thread docs/md-vs-ipynb.md
Comment thread docs/md-vs-ipynb.md
Copy link
Copy Markdown
Contributor

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Thanks @choldgraf, this new edits addressed my points.

@agoose77
Copy link
Copy Markdown
Contributor

@bsipocz is happy with the edits, and I think this is a much needed document! I'll merge it now, because I also share @bsipocz's views, and it's safe to try.

@agoose77 agoose77 merged commit 5a12e4b into main Apr 17, 2025
5 checks passed
@agoose77 agoose77 deleted the md-ipynb-guidance branch April 17, 2025 18:44
Comment thread docs/md-vs-ipynb.md Outdated

**`.md`** is a plain text file with markdown inside. It is more human-readable, and slightly less-structurd than JSON files. It focused on the **input cells** and **markdown cells** of a Jupyter Notebook, as well as **human-generated metadata** (like cell tags). Markdown notebooks **do not store outputs**. If you execute a cell with a Markdown-based Jupyter Notebook, then outputs will exist in your interactive session but not be saved to the `.md` file. This makes **code review and version control much easier** because you're only looking at markdown and some human-generated syntax for code cells. Finally, Jupyter UIs require installing either [Jupytext](https://jupytext.readthedocs.io/) or [JupyterLab-MyST](https://github.com/jupyter-book/jupyterlab-myst) to read markdown-based notebooks.

### When to lean towards `.ipynb`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What about in a situation where you are interested in users being able to use the notebook on a JupyterHub instance? I guess this is effectively covered in the Out-of-the-box Jupyter UI support: but is it an example of a use case where .ipynb would be preferable?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it depends less on the interaction context and more the nature of the work. If you're using a hub to share fast reproducible notebooks, then .md is probably preferred (and the image author should ensure that the relevant plugins are installed). Otherwise, you'd probably lean towards ipynb files.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Got it. I guess I am thinking about instances in an instructional context (such as Berkeley's DataHub), but I guess that the request can be made to make sure that the relevant packages are available across the JupyterHub instance for the .md notebook rendering (or less ideally they can be installed locally each time).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for instructional context I very strongly prefer md as those material coming from well curated and version controlled repos and are written with the purpose that the users are interacting with it, rather than a frozen in time science product. (e.g. I'm ok with an ipynb as an attachment to a paper or similar when it's more like a showcase that stuff did run at some time; rather than the all should still work and reproduce).

@bsipocz
Copy link
Copy Markdown
Contributor

bsipocz commented Apr 19, 2025

@choldgraf - when will this end up in the deployed website? I cannot really tell that from the configs, or if the website is tied to a released version or is from main, etc.

@choldgraf
Copy link
Copy Markdown
Collaborator Author

choldgraf commented Apr 19, 2025

At the moment, I believe that the only way to update the mystmd.org docs is for @rowanc1 to manually deploy it. I've got this issue tracking the need to share that ability with other team members but we haven't actioned it yet:

So for now there's nothing I can do. Rowan usually does this when there is a new release and/or whenever he has some spare cycles to do it.

@rowanc1
Copy link
Copy Markdown
Member

rowanc1 commented Apr 19, 2025

We do this on version releases, yes. Can get it done soon.

fk128 pushed a commit to fk128/mystmd that referenced this pull request Jul 30, 2025
…k#1969)

* Add a brief guide to choosing between  and

* Update docs/md-vs-ipynb.md

Co-authored-by: Brigitta Sipőcz <b.sipocz@gmail.com>

* comments

---------

Co-authored-by: Brigitta Sipőcz <b.sipocz@gmail.com>
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.

5 participants