<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Jupyter Blog - Marc Wouts</title><link href="https://jasongrout.github.io/medium-archive/pelican/" rel="alternate"/><link href="https://jasongrout.github.io/medium-archive/pelican/feeds/author-marc-wouts.atom.xml" rel="self"/><id>https://jasongrout.github.io/medium-archive/pelican/</id><updated>2024-03-19T18:39:00+00:00</updated><subtitle>The Project Jupyter blog: news, releases, and community stories, archived from blog.jupyter.org.</subtitle><entry><title>Make your Pandas or Polars DataFrames Interactive with ITables 2.0</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2024/make-your-pandas-or-polars-dataframes-interactive-with/" rel="alternate"/><published>2024-03-19T18:39:00+00:00</published><updated>2024-03-19T18:39:00+00:00</updated><author><name>Marc Wouts</name></author><id>tag:jasongrout.github.io,2024-03-19:/medium-archive/pelican/posts/2024/make-your-pandas-or-polars-dataframes-interactive-with/</id><summary type="html">&lt;p&gt;ITables, or Interactive Tables, is a MIT-licensed Python package that renders Python DataFrames using the DataTables JavaScript library…&lt;/p&gt;
</summary><content type="html">&lt;p&gt;ITables, or Interactive Tables, is a MIT-licensed Python package that renders Python DataFrames using the &lt;a href="https://datatables.net/"&gt;DataTables&lt;/a&gt; JavaScript library. ITables 2.0, that I have just released, adds support for the DataTables Extensions. In this post we review the functionalities brought by this release.&lt;/p&gt;
&lt;h2 id="how-to-use-itables-and-what-you-get"&gt;How to use ITables, and what you get&lt;/h2&gt;
&lt;p&gt;ITables can be installed using either pip or conda:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;itables
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;conda&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;itables
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;ITables is essentially a Python wrapper for &lt;a href="https://datatables.net/"&gt;DataTables&lt;/a&gt;. We have managed to keep its dependencies to a minimum: ITables only requires &lt;code&gt;IPython&lt;/code&gt;, &lt;code&gt;pandas&lt;/code&gt; and &lt;code&gt;numpy&lt;/code&gt;, which you must already have if you use Pandas in Jupyter (add &lt;code&gt;polars&lt;/code&gt; and &lt;code&gt;pyarrow&lt;/code&gt; if you wish to use ITables with Polars DataFrames).&lt;/p&gt;
&lt;p&gt;To use ITables in your notebook, run this code snippet:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;itables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;init_notebook_mode&lt;/span&gt;

&lt;span class="n"&gt;init_notebook_mode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;all_interactive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After that, every Pandas or Polars DataFrame will be displayed using the &lt;a href="https://datatables.net/"&gt;DataTables&lt;/a&gt; library. With DataTables, you get an easier and more complete access to your data. You can expand the table, explore the various pages, sort the data or even search through it, without having to go back to the Python prompt.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="A Pandas DataFrame rendered with ITables" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/make-your-pandas-or-polars-dataframes-interactive-with/images/001-1_kPeW6sSz3obRCxM50U6QAA.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;A Pandas DataFrame rendered with ITables&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;To render only specific tables as interactive DataTables, or pass arguments to the DataTable constructor, you can use the &lt;code&gt;show&lt;/code&gt; function:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;itables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;show&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="a-brief-history-of-itables"&gt;A brief history of ITables&lt;/h2&gt;
&lt;p&gt;I started the ITables project back in 2019. The full changelog is available &lt;a href="https://mwouts.github.io/itables/changelog.html"&gt;here&lt;/a&gt;, but let me highlight a few important milestones:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;v1.0 (June 2022): Offline mode&lt;/li&gt;
&lt;li&gt;v1.2 (Aug 2022): In addition to Jupyter Lab, Notebook, Book, HTML export, VS Code, PyCharm, Google Colab, RISE presentations, Voilà applications, ITables works in &lt;a href="https://mwouts.github.io/itables/supported_editors.html#using-itables-in-shiny"&gt;Shiny&lt;/a&gt; applications&lt;/li&gt;
&lt;li&gt;v1.3.5 (Nov 2022): Large tables are fast too&lt;/li&gt;
&lt;li&gt;v1.5 (March 2023): Polars DataFrames are supported&lt;/li&gt;
&lt;li&gt;v1.6 (Sep 2023): &lt;a href="https://mwouts.github.io/itables/pandas_style.html"&gt;Pandas Style&lt;/a&gt; objects can be displayed with ITables&lt;/li&gt;
&lt;li&gt;v1.7 (Feb 2024): ITables works with &lt;a href="https://mwouts.github.io/itables/quarto.html"&gt;Quarto&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;v2.0 (March 2024): ITables support the &lt;a href="https://mwouts.github.io/itables/extensions.html"&gt;DataTables Extensions&lt;/a&gt;!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It took me much research (and two years I am afraid) to reach v2 and the DataTables Extensions. But we’re finally there! Let’s review what these extensions mean to your data workflow.&lt;/p&gt;
&lt;h2 id="my-favorite-datatables-extensions"&gt;My favorite DataTables Extensions&lt;/h2&gt;
&lt;h3 id="download-your-data"&gt;Download your data!&lt;/h3&gt;
&lt;p&gt;If you think of a Jupyter Notebook, it might sound strange that we are considering downloading the table data, since we have it already in the Python session. Actually, ITables does not stop at the Notebook. The interactive DataTables continue to be interactive even if you export the notebook to an HTML document with e.g. Jupyter &lt;a href="https://nbconvert.readthedocs.io"&gt;nbconvert&lt;/a&gt; (&lt;code&gt;jupyter nbconvert --to html&lt;/code&gt;). The are also interactive in a &lt;a href="https://github.com/jupyterlab-contrib/rise"&gt;RISE&lt;/a&gt; or &lt;a href="https://quarto.org/docs/presentations/"&gt;Quarto&lt;/a&gt; presentation. ITables also works in &lt;a href="https://jupyterbook.org/"&gt;Jupyter Book&lt;/a&gt; (which we use for the ITables &lt;a href="https://mwouts.github.io/itables"&gt;documentation&lt;/a&gt;), and in interactive applications build with e.g. &lt;a href="https://voila.readthedocs.io"&gt;Voilà&lt;/a&gt; or &lt;a href="https://mwouts.github.io/itables/supported_editors.html#using-itables-in-shiny"&gt;Shiny&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hopefully it’s clearer now why we might want to make the data downloadable! And the good news is that, with the &lt;a href="https://mwouts.github.io/itables/extensions.html#buttons"&gt;Buttons&lt;/a&gt; extension of DataTables, is it as easy as:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;show&lt;span class="o"&gt;(&lt;/span&gt;df,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;buttons&lt;/span&gt;&lt;span class="o"&gt;=[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;copyHtml5&amp;quot;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;csvHtml5&amp;quot;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;excelHtml5&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;figure&gt;
&lt;img alt="The Copy/CSV/Excel buttons" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/make-your-pandas-or-polars-dataframes-interactive-with/images/002-1_zuo-oFLtcb1Yw05oGRUTNg.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;The Copy/CSV/Excel &lt;a href="https://mwouts.github.io/itables/extensions.html#buttons"&gt;buttons&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h3 id="cascade-search"&gt;Cascade search&lt;/h3&gt;
&lt;p&gt;The &lt;a href="https://mwouts.github.io/itables/extensions.html#searchpanes"&gt;SearchPanes&lt;/a&gt; extension lets you proceed to a quick and visual search through the columns that have repeated values:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="The SearchPanes extension" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/make-your-pandas-or-polars-dataframes-interactive-with/images/003-1_pMZabsjGnznieY-wjpn8HQ.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;The &lt;a href="https://mwouts.github.io/itables/extensions.html#searchpanes"&gt;SearchPanes&lt;/a&gt; extension&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h3 id="search-builder"&gt;Search builder&lt;/h3&gt;
&lt;p&gt;I find the &lt;a href="https://mwouts.github.io/itables/extensions.html#searchbuilder"&gt;SearchBuilder&lt;/a&gt; extension very useful. Also, I love the option to set a pre-defined search and display only the part of the dataset we want to focus on.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="The SearchBuilder extension" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/make-your-pandas-or-polars-dataframes-interactive-with/images/004-1_U3_wuju-3UVQRWRxHo2Gmw.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;The &lt;a href="https://mwouts.github.io/itables/extensions.html#searchbuilder"&gt;SearchBuilder&lt;/a&gt; extension&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id="downsampling"&gt;Downsampling&lt;/h2&gt;
&lt;p&gt;Last but not least, I need to tell you about ITables’ &lt;a href="https://mwouts.github.io/itables/downsampling.html"&gt;down-sampling&lt;/a&gt; mechanism. By default, only a subset of the table with an estimated size of not more than 64kB (and not more than 200 columns) is displayed. You can change this with e.g.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;itables.options&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;opt&lt;/span&gt;

&lt;span class="n"&gt;opt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;maxBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;131072&lt;/span&gt;
&lt;span class="n"&gt;opt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;maxColumns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can tell whether your table was down-sampled by looking at the table summary at the bottom right of your table.&lt;/p&gt;
&lt;p&gt;Please keep the following in mind: when down-sampling occurs, only a fraction of the data is passed on to DataTables, and hence the search or data export functions will only have access to that partial dataset.&lt;/p&gt;
&lt;p&gt;Down-sampling is what makes ITables fast. Think twice before setting &lt;code&gt;opt.maxBytes&lt;/code&gt; to a large number or to &lt;code&gt;0&lt;/code&gt;, as this might well freeze your notebook. Displaying a 1G DataFrame will make your notebook at least as big (probably bigger as the data is exported to JSON), and it’s not clear that your browser will support this.&lt;/p&gt;
&lt;h2 id="acknowledgments"&gt;Acknowledgments&lt;/h2&gt;
&lt;p&gt;ITables would not exist without the beautiful &lt;a href="https://datatables.net/"&gt;DataTables&lt;/a&gt; JavaScript library. The DataTables library (MIT license) is authored and maintained by &lt;a href="https://github.com/AllanJard"&gt;Allan Jardine&lt;/a&gt;. DataTables has a great documentation, many examples, and also a useful forum. Allan also provided precious advice on how to bundle the extensions with ITables.&lt;/p&gt;
&lt;p&gt;The point in using DataTables in the context of data exploration and analysis had been demonstrated prior to ITables by the &lt;a href="https://rstudio.github.io/DT/"&gt;DT&lt;/a&gt; package for R.&lt;/p&gt;
&lt;p&gt;Last but not least, ITables owes a lot to my brother &lt;a href="https://fwouts.com/"&gt;François Wouts&lt;/a&gt;. François patiently helped me find a way to provide DataTables and its extensions that would be compatible with all the &lt;a href="https://mwouts.github.io/itables/supported_editors.html"&gt;editors&lt;/a&gt; and rendering contexts that we want to support in ITables.&lt;/p&gt;
</content><category term="widgets"/></entry><entry><title>The Jupytext Menu is back!</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/" rel="alternate"/><published>2024-01-31T20:29:00+00:00</published><updated>2024-01-31T20:29:00+00:00</updated><author><name>Marc Wouts</name></author><id>tag:jasongrout.github.io,2024-01-31:/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/</id><summary type="html">&lt;p&gt;A few weeks back, jupytext==1.16.0 went out. That release included multiple amazing contributions by Mahendra Paipuri, this post will go…&lt;/p&gt;
</summary><content type="html">&lt;p&gt;A few weeks back, &lt;code&gt;jupytext==1.16.0&lt;/code&gt; went out. That release included multiple amazing contributions by &lt;a href="https://github.com/mahendrapaipuri"&gt;Mahendra Paipuri&lt;/a&gt;, this post will go over the new features, and thank Mahendra for his great work.&lt;/p&gt;
&lt;p&gt;As we will see below, Mahendra restored the Jupytext Menu, made the extension fully compatible with JupyterLab 4 and Jupyter Notebook 7, and added the option to create Text Notebooks directly from the launcher.&lt;/p&gt;
&lt;h2 id="what-is-jupytext"&gt;What is Jupytext&lt;/h2&gt;
&lt;p&gt;Jupytext is a Python package that lets you save Jupyter Notebooks as text notebooks. Multiple formats are supported, and the notebooks can be saved either as &lt;a href="https://jupytext.readthedocs.io/en/latest/formats-markdown.html"&gt;Markdown documents&lt;/a&gt; with a &lt;code&gt;.md&lt;/code&gt; extension, or as &lt;a href="https://jupytext.readthedocs.io/en/latest/formats-scripts.html"&gt;scripts&lt;/a&gt; with e.g. a &lt;code&gt;.py&lt;/code&gt; extension (assuming you use Python - otherwise multiple &lt;a href="https://jupytext.readthedocs.io/en/latest/languages.html"&gt;languages&lt;/a&gt; are supported).&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;.py&lt;/code&gt; notebook in the percent format looks like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# %% [markdown]&lt;/span&gt;
&lt;span class="c1"&gt;# This is a markdown cell&lt;/span&gt;

&lt;span class="c1"&gt;# %%&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="c1"&gt;# %%&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To open a text notebook as a notebook in Jupyter, right-click on the document and select “Notebook” (you can also change the default viewer to “Jupytext Notebook” if you wish: see below the section about the settings)&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Right click to open a text notebook with the Notebook editor" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/images/001-1_OekPCzL8Obv0NYracG_-uA.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Right click to open a text notebook with the Notebook editor&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Text notebooks are conveniently edited and executed in Jupyter as notebooks:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="A Text Notebook in JupyterLab" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/images/002-1_J6-ToiGplGQFE0eQTWo0iw.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;A Text Notebook in JupyterLab&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;You can also edit them with your favorite text editor. You will get the changes back in Jupyter by re-opening or by &lt;em&gt;reloading&lt;/em&gt; the document: click e.g. on &lt;em&gt;reload Python file from disk&lt;/em&gt; in the &lt;em&gt;File&lt;/em&gt; menu.&lt;/p&gt;
&lt;p&gt;Text notebooks only contain the notebook inputs. For that reason they use much less disk space than &lt;code&gt;.ipynb&lt;/code&gt; notebooks. They are also better suited for version control as they only contain the content that was actually typed by the user. But even more useful are &lt;em&gt;paired&lt;/em&gt; notebooks: text notebooks paired with an &lt;code&gt;.ipynb&lt;/code&gt; notebook where the notebook outputs are preserved. When a paired notebook is saved, Jupytext writes the notebook to both files. When the notebook is read or reloaded in Jupyter, the notebook inputs are loaded from the most recent file, meaning that any edits on the text notebook will be reflected in Jupyter (and propagated to the &lt;code&gt;.ipynb&lt;/code&gt; file the next time it is saved).&lt;/p&gt;
&lt;h2 id="the-jupytext-menu-is-back"&gt;The Jupytext Menu is back!&lt;/h2&gt;
&lt;p&gt;One of the most frequent operation when using Jupytext is to &lt;em&gt;pair&lt;/em&gt; an &lt;code&gt;.ipynb&lt;/code&gt; notebook with a text notebook in the format of your choice.&lt;/p&gt;
&lt;p&gt;In earlier versions of Jupytext, pairing a notebook had to be done through the command palette.&lt;/p&gt;
&lt;p&gt;In Jupytext v1.16, thanks to Mahendra’s work on the front-end extension, you can directly use the Jupytext Menu for this. And the menu is available for both JupyterLab 4 and Jupyter Notebook 7!&lt;/p&gt;
&lt;p&gt;If you are new to Jupytext, we recommend that you pair your &lt;code&gt;.ipynb&lt;/code&gt; notebooks with either a &lt;em&gt;percent script&lt;/em&gt; or with a MyST Markdown file. The former format works well if you want to save and edit your notebook as a script, while the latter is well suited for writing documentation.&lt;/p&gt;
&lt;p&gt;Once you have paired the notebook with a Jupytext format, save your notebook, and the paired files will be created or updated.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="The Jupytext Menu" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/images/003-1_luqGwTI9TbORaPjfsquNIQ.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;The Jupytext Menu&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id="creating-new-text-notebooks"&gt;Creating new text notebooks&lt;/h2&gt;
&lt;p&gt;For some notebooks you might decide that you don’t need to save the outputs at all. In that case you can work with an (unpaired) text notebook.&lt;/p&gt;
&lt;p&gt;To create a text notebook you can use the &lt;em&gt;New Text Notebook&lt;/em&gt; sub-menu under &lt;em&gt;File&lt;/em&gt;:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Create Text Notebooks directly from the menu" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/images/004-1_YLrRNo1MKSPrUSo1wwjsBQ.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Create Text Notebooks directly from the menu&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;If, later on, you decide that you want to preserve the notebook outputs in a &lt;em&gt;paired&lt;/em&gt; &lt;code&gt;.ipynb&lt;/code&gt; notebooks, you will just have to &lt;em&gt;pair&lt;/em&gt; the document to an &lt;code&gt;.ipynb&lt;/code&gt; notebook using the Jupytext Menu documented at the previous paragraph.&lt;/p&gt;
&lt;h2 id="text-notebooks-in-the-launcher"&gt;Text Notebooks in the launcher&lt;/h2&gt;
&lt;p&gt;In Jupytext v1.16, thanks to Mahendra’s work on the front end, text notebooks are also available in a Jupytext section in the Jupyter launcher:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Text Notebooks are also available in the launcher" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/images/005-1_P_0hx6p-nfwkDpqHGJmewg.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Text Notebooks are also available in the launcher&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id="jupytext-settings-in-jupyterlab"&gt;Jupytext Settings in JupyterLab&lt;/h2&gt;
&lt;p&gt;Since there are many possible formats for text notebooks, we have decided to expose only the most common ones, by default, in the launcher and in the &lt;em&gt;New Text Notebook&lt;/em&gt; menu.&lt;/p&gt;
&lt;p&gt;You can include more formats in the menu and in the launcher by changing the Jupytext settings in the &lt;em&gt;Settings Editor&lt;/em&gt; (in the &lt;em&gt;Settings&lt;/em&gt; menu):&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="The Jupytext Menu/Launcher settings" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/images/006-1_n31jAKcy96wrrTYR3qCuXA.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;The Jupytext Menu/Launcher settings&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;You might also want to open certain text documents as notebooks with a single click. You can achieve this by setting the default viewer for those documents to “Jupytext Notebook”. For instance, if you want to open &lt;code&gt;.py&lt;/code&gt; and &lt;code&gt;.md&lt;/code&gt; files as notebooks with a single click, you can configure the default viewers like this:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Changing the default viewers to open Text Notebooks with a single click" src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/the-jupytext-menu-is-back/images/007-1_1oj4Jrdz8hOhG90rYZckEA.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Changing the default viewers to open Text Notebooks with a single click&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Alternatively, you can also list and set the default viewers with the &lt;code&gt;jupytext-config&lt;/code&gt; utility (which was developed recently by Thierry Parmentelat), using e.g.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;jupytext-config&lt;span class="w"&gt; &lt;/span&gt;set-default-viewer&lt;span class="w"&gt; &lt;/span&gt;python&lt;span class="w"&gt; &lt;/span&gt;markdown
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;to set “Jupytext Notebook” as the default viewer for both Python and Markdown files.&lt;/p&gt;
&lt;h2 id="pairing-notebooks-globally"&gt;Pairing notebooks globally&lt;/h2&gt;
&lt;p&gt;The pairing commands provided through the Jupytext Menu and commands act on individual notebooks, by settings a &lt;code&gt;jupytext.formats&lt;/code&gt; metadata in the notebook.&lt;/p&gt;
&lt;p&gt;It is also possible to pair all the notebooks within a certain folder using a &lt;code&gt;jupytext.toml&lt;/code&gt; configuration file - see &lt;a href="https://jupytext.readthedocs.io/en/latest/config.html"&gt;Jupytext’s documentation&lt;/a&gt;. Please note that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The local metadata in the notebook takes precedence over the global configuration, and&lt;/li&gt;
&lt;li&gt;Jupyter is aware of the global &lt;code&gt;jupytext.toml&lt;/code&gt; file and will pair the notebooks accordingly, however the Jupytext Menu is not aware of the global configuration, so the paired formats selected through the global configuration will not be checked in the menu.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="installing-jupytext-v116"&gt;Installing Jupytext v1.16&lt;/h2&gt;
&lt;p&gt;The front end extension for JupyterLab shipped with Jupytext v1.16 requires JupyterLab 4, and/or Jupyter Notebook 7. Please upgrade Jupyter accordingly. Then, install Jupytext with&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;jupytext&amp;gt;=1.16.0&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;conda&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;jupytext&amp;gt;=1.16.0&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-c&lt;span class="w"&gt; &lt;/span&gt;conda-forge
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and restart your Jupyter server with e.g. &lt;code&gt;jupyter lab&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="acknowledgments"&gt;Acknowledgments&lt;/h2&gt;
&lt;p&gt;I would like to thank &lt;a href="https://github.com/mahendrapaipuri"&gt;Mahendra Paipuri&lt;/a&gt; for his impressive work. I am pretty sure that the Jupytext Menu, and the option to create new text notebooks, will be much appreciated by Jupytext users!&lt;/p&gt;
&lt;p&gt;While users will mostly notice Mahendra’s work on the front end extension, it was actually not his only contribution to this release! Mahendra also thoroughly revisited the packaging of Jupytext, and helped us transition the project to the &lt;code&gt;src&lt;/code&gt; layout, and our old &lt;code&gt;setup.py&lt;/code&gt; to an up-to-date &lt;code&gt;pyproject.toml&lt;/code&gt; configuration that uses &lt;code&gt;hatch&lt;/code&gt; to build Jupytext.&lt;/p&gt;
&lt;p&gt;I also want to thank &lt;a href="https://github.com/LecrisUT"&gt;Cristian Le&lt;/a&gt; for his precious advice regarding the layout refactoring, and for helping us to tackle the CI reorganization. &lt;a href="https://github.com/parmentelat"&gt;Thierry Parmentelat&lt;/a&gt;, who had previously ported the front-end extension to JupyterLab 4, contributed much testing and feedback on this new version of the front-end extension.&lt;/p&gt;
&lt;p&gt;It is always a pleasure for me to maintain Jupytext, an amazing adventure that started five years ago already. However, I can get busy at times (Jupytext comes in addition to my day job, one cat, two bikes, three kids), so I am really thankful for receiving such contributions, especially when they are of such a great quality!&lt;/p&gt;
</content><category term="documentation"/></entry></feed>