Skip to content

Update ipynb file with data from stdin fails #1282

@goerz

Description

@goerz

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions