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

Update ipynb file with data from stdin fails #1282

Closed
goerz opened this issue Dec 6, 2024 · 2 comments · Fixed by #1284
Closed

Update ipynb file with data from stdin fails #1282

goerz opened this issue Dec 6, 2024 · 2 comments · Fixed by #1284
Assignees

Comments

@goerz
Copy link

goerz commented Dec 6, 2024

Trying to update a notebook with data coming from stdin fails. Steps to reproduce:

  • Start with a notebook file notebook.ipynb (does not need to be paired)
  • Create a notebook.md file by running jupytext --to=markdown notebook.ipynb
  • Verify that jupytext --to=ipynb --output notebook.ipynb --update notebook.md works
  • Run cat notebook.md | jupytext --to=ipynb --output notebook.ipynb --update, which should be equivalent.

This errors with jupytext.formats.JupytextFormatError: No format associated to extension '.'. The reason is that jupytext tries to get a file extension from the input file (stdin in this case) in check_file_version.

However, this is unnecessary, as the input data contains the following in the YAML header:

---
jupyter:
  jupytext:
    text_representation:
      extension: .md
      format_name: markdown
      format_version: '1.3'
      jupytext_version: 1.16.4
  kernelspec:
    display_name: Python 3 (ipykernel)
    language: python
    name: python3
---

Jupytext could get all the required information from this metadata (the jupytext.text_representation.extension, in particular).

Being able to update from stdin would be extremely helpful in a rewrite of jupytext.nvim that avoids the use of temporary files.

@mwouts
Copy link
Owner

mwouts commented Dec 7, 2024

Hey @goerz , sure that makes sense! Would you like to give a try at #1284 and let me know if it would work for you? Thanks

@goerz
Copy link
Author

goerz commented Dec 8, 2024

Yes, it works perfectly!

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 a pull request may close this issue.

2 participants