question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jupytext.write doesn't error if `fmt` is unknown, but the output file has a known extension

See original GitHub issue

Just playing around with MyST -> ipynb -> MyST right now. The ipynb syncing works beautifully! I love it

I am having a hard time getting MyST code cells to render as ipynb code cells.

E.g., this markdown:

---
jupytext:
  formats: ipynb,md:myst
  text_representation:
    extension: .md
    format_name: myst
    format_version: '0.6'
    jupytext_version: 1.4.1
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

```{code-cell} python3
print('hi')
```


```{code-cell} python3
print('hi')
```

has its ```{code-cell} ``` read in as markdown instead of being converted to Python code cells.

I tried adding double-spaces between them but that didn’t do the trick. Anything I am missing?

(I also noticed a weird thing where the YAML header of the MyST markdown file would be read into the notebook as a raw cell at the top, rather than in the notebook metadata…is that expected behavior?)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mwoutscommented, Mar 20, 2020

Thanks @choldgraf , that is a good point… I agree that jupytext.write should raise an error in that case. I’ll see how to add a test and fix that.

0reactions
choldgrafcommented, Mar 19, 2020

ahhh yes, I believe that myst-parser was a key issue here. I’ve upgraded it and it now works much better! Amazing 😃

One thing that I think exacerbated my problem, if I write the notebook to markdown and give a fmt= value that jupytext doesn’t have, then jupytext still writes the format just fine. E.g., this works:

image

I think what it is doing is inferring the output type from the .md extension of teh output, because if I remove the .md then it throws an error. However, I think jupytext should throw a warning if it doesn’t understand the fmt= value, and instead is going to infer from the file extension. This was confusing me, because I was writing jupytext.write(ntbk, "out.md", fmt="myst"), when I should have been writing jupytext.write(ntbk, "out.md", fmt="md:myst"), but because no error or warning was thrown, it was just defaulting to “regular” markdown.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jupytext documentation
When Jupytext is installed, .py and .md files have a notebook icon. ... The Jupytext extension for JupyterLab is bundled with Jupytext.
Read more >
nbsphinx - Read the Docs
If you don't know how to create a PDF file from the LaTeX output, you should have ... The nbsphinx extension does not...
Read more >
Release 0.21.7 ploomber
In a Ploomber pipeline, outputs (also known as products) from one task become inputs of “downstream” tasks. Hence,.
Read more >
Executables in CoCalc
On CoCalc, you can also install or compile your own executable binaries. You have a lot of control about your own project, which...
Read more >
Supplement of EUREC A's HALO - ESSD
Later on, we want to plot all flights on an interactive map. Currently the dataset is rather large as the aircraft location has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found