<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Jupyter Blog - Mariana Meireles</title><link href="https://jasongrout.github.io/medium-archive/pelican/" rel="alternate"/><link href="https://jasongrout.github.io/medium-archive/pelican/feeds/author-mariana-meireles.atom.xml" rel="self"/><id>https://jasongrout.github.io/medium-archive/pelican/</id><updated>2023-01-10T18:33:00+00:00</updated><subtitle>The Project Jupyter blog: news, releases, and community stories, archived from blog.jupyter.org.</subtitle><entry><title>Looking at notebooks from a new perspective</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/" rel="alternate"/><published>2021-10-05T08:33:00+00:00</published><updated>2021-10-05T09:48:00+00:00</updated><author><name>Mariana Meireles</name></author><id>tag:jasongrout.github.io,2021-10-05:/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/</id><summary type="html">&lt;p&gt;How to better communicate with Jupyter notebooks&lt;/p&gt;
</summary><content type="html">&lt;figure&gt;
&lt;img alt="Illustration by Juliette Taka" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/images/001-1_g3OWLubcUFgVIGBfPYztJQ.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Illustration by &lt;a href="http://juliettetaka.com"&gt;Juliette Taka&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Jupyter notebooks are a great tool for practitioners of scientific computing from the research phase of their work to the communication of their results. The interleaving of code and rich text makes notebooks an ideal tool to communicate the complex ideas underlying computational concepts. However, depending on the context, we might want to look at the same source material (the notebook document) with different glasses, to present the content as a slideshow, or to audiences who are not comfortable with code.&lt;/p&gt;
&lt;p&gt;One may also want to provide statically-rendered content rather than a fully-fledged executable notebook for security reasons. For each context, we should be able to adapt the notebook’s aesthetics and behavior to our needs.&lt;/p&gt;
&lt;p&gt;Fortunately, the Jupyter ecosystem offers a broad range of tools to give a new face to notebooks and adjust them to one’s needs.&lt;/p&gt;
&lt;h2 id="panoramic-view-of-visualization-tools-on-the-jupyter-ecosystem"&gt;Panoramic view of visualization tools on the Jupyter ecosystem&lt;/h2&gt;
&lt;p&gt;The two main tools in the Jupyter ecosystem for rendering notebooks in a customized fashion are &lt;strong&gt;nbconvert&lt;/strong&gt; and &lt;strong&gt;Voilà&lt;/strong&gt;. In this post, we go over the differences and similarities between these two tools.&lt;/p&gt;
&lt;p&gt;nbconvert and Voilà have the same conversion process, the main difference lies in the outcome generated by each tool. While nbconvert outputs static, non-interactive documents, Voilà converts your notebook to a fully interactive application and the way it achieves that is by keeping a Jupyter kernel active at all times.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Simplified scheme of nbconvert and Voilà’s internals" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/images/002-1_zvARwLB6MAyyb4Q_K4Gx3w.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Simplified scheme of nbconvert and Voilà’s internals&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Whichever is the format you chose to generate your notebook, end-users won’t be able to execute arbitrary code, providing a secure way of sharing your results with others.&lt;/p&gt;
&lt;h3 id="nbconvert"&gt;&lt;strong&gt;nbconvert&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://github.com/jupyter/nbconvert"&gt;Nbconvert&lt;/a&gt; converts notebooks to various other formats via &lt;a href="http://jinja.pocoo.org/"&gt;Jinja&lt;/a&gt; templates. It allows you to convert a &lt;code&gt;.ipynb&lt;/code&gt; notebook file into various static formats:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;LaTeX&lt;/li&gt;
&lt;li&gt;PDF&lt;/li&gt;
&lt;li&gt;Markdown document&lt;/li&gt;
&lt;li&gt;ReStructured Text&lt;/li&gt;
&lt;li&gt;Executable Script&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;nbconvert is a very versatile tool and can be used not only with the purpose of sharing your code and/or results with peers but also to create tests instances for your Jupyter notebooks and even generate blog posts. You can find more information about its possibilities in the &lt;a href="https://nbconvert.readthedocs.io"&gt;docs&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="voila"&gt;&lt;strong&gt;Voilà&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://github.com/voila-dashboards/voila"&gt;Voilà&lt;/a&gt; brings the versatility of nbconvert while allowing you to interact with your code outputs safely both in the Notebook and Lab interface.&lt;/p&gt;
&lt;p&gt;As pointed out before, Voilà keeps a Jupyter kernel instance running at all times. It is language-agnostic and it will run any language supported by Jupyter. Furthermore, as it encapsulates nbconvert, Voilà is capable of converting the notebook to any of its output formats as well as make use of all of the templates that come with nbconvert.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Rendering interactive Matplotlib figures in a web application with Voilà. Source." src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/images/003-0_OtsvahHJvfEvcziO.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Rendering interactive Matplotlib figures in a web application with Voilà. &lt;a href="/posts/2019/and-voila/"&gt;Source&lt;/a&gt;.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;You will notice that Voilà expands on the default templates: from simple one-page documents to complex grid-based dashboards and slideshows.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Grid template generated by Voilà" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/images/004-1_Fh9khuZcEG98Fz1F-AZ83A.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Grid template generated by Voilà&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id="slideshows-with-jupyter"&gt;Slideshows with Jupyter&lt;/h2&gt;
&lt;p&gt;A common use case is to share the results as a slideshow. Let’s look at the different ways to do so.&lt;/p&gt;
&lt;p&gt;The first step to set up your slideshow is to define the mapping between cells and slides. This mapping is saved in the cell metadata of the notebook, and JupyterLab has the appropriate built-in tool to edit this information.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Different kinds of metadata that can be added to a cell on JupyterLab" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/images/005-1_7psFVJ14ekqdgi7n3ZwS-Q.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Different kinds of metadata that can be added to a cell on JupyterLab&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The classic notebook offers a similar interface to edit the notebook metadata. Then, to visualize the resulting slideshow, several tools are available:&lt;/p&gt;
&lt;h3 id="rise"&gt;RISE&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://github.com/damianavila/RISE"&gt;RISE&lt;/a&gt; is a classic notebook extension that provides a toolbar button to turn the notebook into a slideshow in the main notebook UI.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="RISE from the notebook to slides. Source." src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/images/006-0_eDvRenHayEmKFjfN.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;RISE from the notebook to slides. &lt;a href="https://github.com/damianavila/RISE"&gt;Source&lt;/a&gt;.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Unlike the other solutions presented here, RISE slideshows are still executable in the same way as the notebook, which can be a great feature when teaching a class. However, RISE may not be an appropriate tool to share such a slideshow online because it requires giving access to a notebook server.&lt;/p&gt;
&lt;p&gt;Unfortunately, despite the &lt;a href="https://github.com/damianavila/RISE/pull/381"&gt;effort&lt;/a&gt; of the community RISE still doesn’t offer support for JupyterLab.&lt;/p&gt;
&lt;h3 id="nbconvert-1"&gt;&lt;strong&gt;nbconvert&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Another solution is to use the &lt;strong&gt;Reveal&lt;/strong&gt; template of nbconvert, which will use the same cell metadata as RISE to produce a static slideshow.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;nbconvert presentation.ipynb --to html --template reveal
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Unlike with RISE, for which cells remain executable, the outcome of nbconvert is a static HTML file, and only the already-computed outputs will be displayed.&lt;/p&gt;
&lt;h3 id="voila-1"&gt;Voilà&lt;/h3&gt;
&lt;p&gt;Just like with nbconvert, the Reveal template can be used with Voilà with the &lt;strong&gt;&lt;code&gt;--template reveal&lt;/code&gt;&lt;/strong&gt; command-line argument.&lt;/p&gt;
&lt;p&gt;Using Voilà instead of nbconvert will spawn a kernel for each connected user, enabling the use of interactive widgets in the resulting slideshow to interact with the backend.&lt;/p&gt;
&lt;p&gt;Besides, the default behavior of Voilà is to hide input cells and only display markdown cells and output.&lt;/p&gt;
&lt;h3 id="whats-new-dejavu"&gt;What’s new: Déjàvu!&lt;/h3&gt;
&lt;p&gt;Déjàvu is a new utility included in nbconvert 6.2, which simply specifies new default values for several options so as to mimick Voilà’s behavior with respect to hiding input cells and prompt numbers. However, these defaults can still be overwritten by the end-user. You can do it just like you would if you were using nbconvert.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;jupyter dejavu notebook.ipynb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;figure&gt;
&lt;img alt="Déjàvu output (on the left) and Voilà output (on the right)" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/images/007-1_DqBf2bE3M7ynUy-Kv0qIbA.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Déjàvu output (on the left) and Voilà output (on the right)&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Voilà and Déjàvu’s outputs are identical, although, in the case of Déjàvu, interactions with widgets that require a roundtrip to the kernel will not work. In contrast, we can see the result of the calculation on the Voilà side.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To summarize and wrap up:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Déjàvu supports all of the templates available in Voilà, and even though users don’t have access to interactivity they can still benefit from widgets outputs since they’ll be generated and included on the final file;&lt;/li&gt;
&lt;li&gt;When building a slideshow you can use JupyterLab’s interface to define specific metadata to your cells;&lt;/li&gt;
&lt;li&gt;You can also see your code in Déjàvu’s outputs. Just pass the &lt;code&gt;--show-input&lt;/code&gt; option to the command line.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="acknowledgments"&gt;Acknowledgments&lt;/h2&gt;
&lt;p&gt;Thanks to &lt;a href="http://juliettetaka.com"&gt;Juliette Taka&lt;/a&gt; for creating the illustrations for this blog post.&lt;/p&gt;
&lt;h2 id="about-the-author"&gt;About the author&lt;/h2&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/looking-at-notebooks-from-a-new-perspective/images/008-1_xbhgaimjN9YclTKtIQojGQ.jpg" alt="" loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;My name is &lt;a href="https://twitter.com/mari_meir"&gt;Mariana Meireles&lt;/a&gt;, I’m a software engineer working for &lt;a href="http://quantstack.net/"&gt;QuantStack&lt;/a&gt;. I care deeply about the impacts that technology has in the world and try my best to be the change I want to see by contributing to open source projects that stand upon libre and diverse standards.&lt;br&gt;
I’m currently focusing on the Jupyter ecosystem and advocating for open science and open knowledge whenever I can.&lt;/p&gt;
</content><category term="visualization"/><category term="Voilà"/></entry><entry><title>An SQL solution for Jupyter</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2021/an-sql-solution-for-jupyter/" rel="alternate"/><published>2021-02-03T12:03:00+00:00</published><updated>2023-01-10T18:33:00+00:00</updated><author><name>Mariana Meireles</name></author><id>tag:jasongrout.github.io,2021-02-03:/medium-archive/pelican/posts/2021/an-sql-solution-for-jupyter/</id><summary type="html">&lt;p&gt;xeus-sql: A xeus-sqlite sequel&lt;/p&gt;
</summary><content type="html">&lt;p&gt;A few months ago we released &lt;a href="https://github.com/jupyter-xeus/xeus-sqlite"&gt;xeus-sqlite&lt;/a&gt;, a Jupyter kernel that allows users to make SQLite queries directly from the notebook. With the needs of the Jupyter data science community in mind we decided to expand on this project.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="RDBMSes supported by xeus-sql" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/an-sql-solution-for-jupyter/images/001-1_tbfa_AWoqb-yB1Tk6Uq3ng.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;RDBMSes supported by xeus-sql&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Today, we’re happy to announce the next step of this endeavour, bringing you &lt;a href="https://github.com/jupyter-xeus/xeus-sql"&gt;&lt;strong&gt;xeus-sql&lt;/strong&gt;&lt;/a&gt; a general-purpose database access tool for Jupyter, which allows you to make SQL queries on many different databases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;MySQL&lt;/li&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;li&gt;SQLite3&lt;/li&gt;
&lt;li&gt;DB2&lt;/li&gt;
&lt;li&gt;Oracle&lt;/li&gt;
&lt;li&gt;Firebird&lt;/li&gt;
&lt;li&gt;and any database with an ODBC driver.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To offer all these integrations we rely on the &lt;a href="http://soci.sourceforge.net/"&gt;SOCI&lt;/a&gt; library as the backbone of the project. SOCI abstracts all the different database connections and query details behind a unified C++ API. xeus-sql uses SOCI and &lt;a href="https://github.com/jupyter-xeus/xeus"&gt;xeus&lt;/a&gt; to expose SQL functionalities to Jupyter.&lt;/p&gt;
&lt;p&gt;Xeus-sql, as well as the MySQL, PostgreSQL and SQLite3 backends of SOCI are available on conda-forge, meaning you can install them easily with &lt;strong&gt;conda&lt;/strong&gt; or &lt;a href="https://github.com/mamba-org/mamba"&gt;&lt;strong&gt;mamba&lt;/strong&gt;&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# Installing xeus-sql and the mysql backend
mamba install xeus-sql soci-mysql -c conda-forge
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# Installing xeus-sql and the postgresql backend
mamba install xeus-sql soci-postgresql -c conda-forge
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# Installing xeus-sql and the sqlite backend
mamba install xeus-sql soci-sqlite -c conda-forge
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There are idiosyncrasies between these different SQL backends which we detail in the xeus-sql &lt;a href="http://xeus-sql.readthedocs.io/en/latest/"&gt;documentation&lt;/a&gt; and &lt;a href="https://github.com/jupyter-xeus/xeus-sql/tree/master/examples"&gt;examples&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="visualizing-your-queries"&gt;Visualizing your queries&lt;/h2&gt;
&lt;figure&gt;
&lt;img alt="HTML and text table visualizations for different Jupyter interfaces" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/an-sql-solution-for-jupyter/images/002-1_1cl12TkS8uqKDgXvZCJQtQ.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;HTML and text table visualizations for different Jupyter interfaces&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;You’re probably familiar with visualizing your SQL tables and query results in the form of… tables, of course. Jupyter’s rich display system offers the option of showing them in rich-text display or plain-text display depending on which application you’re using.&lt;/p&gt;
&lt;p&gt;Beyond displaying queries with tables, you can now easily create &lt;a href="https://vega.github.io/vega-lite/"&gt;Vega-Lite&lt;/a&gt; graphs from your query results directly in the notebook:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Running a series of examples on a notebook" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/an-sql-solution-for-jupyter/images/003-1_pyLtQiOV5uzGk-VKAVyD4Q.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Running a series of examples on a notebook&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;To support this feature xeus-sql relies on &lt;a href="https://github.com/Quantstack/xvega"&gt;xvega&lt;/a&gt;, a C++ backend to vega, and custom Jupyter magics for plotting through a mini-language implemented in the &lt;a href="https://github.com/jupyter-xeus/xvega-bindings/"&gt;xvega-bindings&lt;/a&gt; utility library. Besides using the mini-language you can directly provide the JSON specification for your visualization, thanks to contributions by &lt;a href="https://github.com/wangfenjin"&gt;Wang Fenjin&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Vega-Lite is a powerful library and there are many different visualizations you can create from your relational data using xeus-sql. You can see some other examples below:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Examples of different visualizations generated with xeus-sql and xvega-lite by Wang Fenjin" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/an-sql-solution-for-jupyter/images/004-1_Rh5QEx6ntJHJ7gSpxgp29A.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;&lt;a href="https://github.com/wangfenjin/xeus-tidb/blob/develop/examples/TiDB.ipynb"&gt;Examples&lt;/a&gt; of different visualizations generated with xeus-sql and xvega-lite by Wang Fenjin&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;We’re looking forward to exchange with users and learn more about their use cases for xeus-sql and xvega, so if you have any questions please drop them on the public &lt;a href="https://gitter.im/QuantStack/Lobby"&gt;QuantStack chat&lt;/a&gt;, or open an issue at the project’s &lt;a href="https://github.com/jupyter-xeus/xeus-sql"&gt;GitHub page&lt;/a&gt;. As always, contributions are welcome!&lt;/p&gt;
&lt;h3 id="try-it-online"&gt;Try it online!&lt;/h3&gt;
&lt;p&gt;You can try the stable version on Binder without the need of installing anything on your computer just by clicking on the image below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://mybinder.org/v2/gh/jupyter-xeus/xeus-sql/stable?urlpath=lab/tree/examples/XVega%20operations.ipynb"&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/an-sql-solution-for-jupyter/images/005-0_cZCb7p2dP8Y27P7P.webp" alt="" loading="lazy" data-body-image=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="acknowledgements"&gt;Acknowledgements&lt;/h2&gt;
&lt;p&gt;We are grateful to &lt;a href="https://github.com/wangfenjin"&gt;Wang Fenjin&lt;/a&gt; for his contributions with respect to the use of vega specs in xeus-sql. The plotting mini-language was built upon the xvega library by &lt;a href="https://twitter.com/mad_tandon"&gt;Madhur Tandon&lt;/a&gt;. We are also grateful to the &lt;a href="https://github.com/SOCI/soci/"&gt;SOCI&lt;/a&gt; contributors for their awesome package that made this work possible.&lt;/p&gt;
&lt;h2 id="about-the-author"&gt;About the author&lt;/h2&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/an-sql-solution-for-jupyter/images/006-1_S-w69baox7Q1D997a5yKNw.webp" alt="" loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;My name is &lt;a href="https://twitter.com/mari_meir"&gt;Mariana Meireles&lt;/a&gt; and I’m a software developer working for &lt;a href="http://quantstack.net/"&gt;QuantStack&lt;/a&gt;. I care deeply about the impacts that technology has in the world and try my best to be the change I want to see by contributing to open source projects that stand upon libre and diverse standards.&lt;/p&gt;
</content><category term="kernels"/></entry><entry><title>A Jupyter kernel for SQLite</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2020/a-jupyter-kernel-for-sqlite/" rel="alternate"/><published>2020-06-11T08:42:00+00:00</published><updated>2020-12-30T15:29:00+00:00</updated><author><name>Mariana Meireles</name></author><id>tag:jasongrout.github.io,2020-06-11:/medium-archive/pelican/posts/2020/a-jupyter-kernel-for-sqlite/</id><summary type="html">&lt;p&gt;While it is well known in the Python scientific computing community, Jupyter is in fact a language-agnostic development environment…&lt;/p&gt;
</summary><content type="html">&lt;p&gt;While it is well known in the Python scientific computing community, Jupyter is in fact a language-agnostic development environment. High-quality language kernels exist for the main languages of data sciences, such as &lt;a href="https://github.com/jupyter-xeus/xeus-python"&gt;Python&lt;/a&gt;, &lt;a href="https://github.com/jupyter-xeus/xeus-cling"&gt;C++&lt;/a&gt;, &lt;a href="https://github.com/JuniperKernel/JuniperKernel"&gt;R&lt;/a&gt; or &lt;a href="https://github.com/JuliaLang/IJulia.jl"&gt;Julia&lt;/a&gt;.&lt;br&gt;
But another important tool for data science is the SQL family of programming languages. Today, we announce the release of a Jupyter kernel for SQLite.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/a-jupyter-kernel-for-sqlite/images/001-1_pzPTGCJVgIO10N7OwOGWKw.webp" alt="" loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;This new kernel allows the user to use the complete SQLite syntax as well as some extra operations such as opening or closing a database file, or visualizing the data in different ways using Jupyter magics.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="HTML and Text table visualizations for different Jupyter interfaces" src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/a-jupyter-kernel-for-sqlite/images/002-1_Pj5UkLChFO3BIMx7NIDRdA.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;HTML and Text table visualizations for different Jupyter interfaces&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;To make the task of implementing a new Kernel for Jupyter easier, we make use of &lt;a href="https://github.com/jupyter-xeus/xeus"&gt;&lt;strong&gt;Xeus&lt;/strong&gt;&lt;/a&gt;, a library providing a solid implementation of the Jupyter kernel protocol, so that we can focus on implementing the language-specific parts of the kernel.&lt;/p&gt;
&lt;p&gt;As a connection between SQLite’s native C implementation and C++ we’re using SRombauts’ library &lt;a href="https://github.com/SRombauts/SQLiteCpp"&gt;&lt;strong&gt;SQLiteCpp&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="current-state"&gt;Current state&lt;/h2&gt;
&lt;p&gt;xeus-SQLite is still under active development but it offers a fully functional SQLite interface and magics to perform higher-level operations that are outside of the scope of the SQL syntax, such as creating, opening, or closing SQLite databases. Some of the things you can do with xeus-SQLite are creating a new database, loading it, backing it up or deleting it. You can also check if a table exists, set and reset keys of a database and get information about it. You can find more about the use of these methods in SQLite’s &lt;a href="https://xeus-sqlite.readthedocs.io/en/latest/"&gt;documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;xeus-SQLite provides rich HTML display of tables in the Jupyter Notebook and Jupyter Lab. For the Jupyter Console we make use of the &lt;a href="https://github.com/p-ranav/tabulate"&gt;&lt;strong&gt;tabulate&lt;/strong&gt;&lt;/a&gt; library for textual display.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Different commands being executed on xeus-SQLite" src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/a-jupyter-kernel-for-sqlite/images/003-1_BIDimBvS_g8QH5fuHS_QRQ.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Different commands being executed on xeus-SQLite&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id="the-future"&gt;The future&lt;/h2&gt;
&lt;p&gt;For the future of xeus-SQLite we want to create an intuitive form of visualizing data: creating plots, graphs, charts, maps and much more from your SQLite query results, all in the same notebook. Currently we’re exploring the use of &lt;a href="https://vega.github.io/vega/"&gt;&lt;strong&gt;Vega&lt;/strong&gt;&lt;/a&gt; in xeus-SQLite, a declarative language for creating interactive visualization designs and can do bar plots using jupyter magics:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="SQLite query result with bar and table outputs for same query" src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/a-jupyter-kernel-for-sqlite/images/004-1_eWZyoVvu5c_k_Yerv1eT-A.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;SQLite query result with bar and table outputs for same query&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;This feature is still in very early stages and being developed in this &lt;a href="https://github.com/jupyter-xeus/xeus-sqlite/tree/vega-visualization"&gt;branch&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We also plan on producing a static build of xeus-SQLite bundling xeus and the SQLite library into a single executable that can be easily distributed.&lt;/p&gt;
&lt;h3 id="try-it-online"&gt;Try it online!&lt;/h3&gt;
&lt;p&gt;You can try the stable version without the need of installing anything on your computer just by clicking on the image below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://mybinder.org/v2/gh/jupyter-xeus/xeus-sqlite/stable"&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/a-jupyter-kernel-for-sqlite/images/005-1_wiJsOB9OWiAGwuaoycfc0w.webp" alt="" loading="lazy" data-body-image=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This won’t grant you access to the experimental branch where we’re testing, if you’re interested in trying it please check the &lt;a href="https://github.com/jupyter-xeus/xeus-sqlite#installation"&gt;installation&lt;/a&gt; guide and make sure you’re in the right &lt;a href="https://github.com/jupyter-xeus/xeus-sqlite/tree/vega-visualization"&gt;branch&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="installation"&gt;Installation&lt;/h3&gt;
&lt;p&gt;Note that you first need to have Jupyter installed on your computer. You can install &lt;code&gt;xeus-sqlite&lt;/code&gt; using mamba:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mamba install xeus-sqlite -c conda-forge
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or conda:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;conda install xeus-sqlite -c conda-forge
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="about-the-author"&gt;About the author&lt;/h2&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/a-jupyter-kernel-for-sqlite/images/006-1_S-w69baox7Q1D997a5yKNw.webp" alt="" loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;My name is &lt;a href="https://twitter.com/mari_meir"&gt;Mariana Meireles&lt;/a&gt; and I’m a software developer working for &lt;a href="http://quantstack.net/"&gt;QuantStack&lt;/a&gt;. I care deeply about the impacts that technology has in the world and try my best to be the change I want to see by contributing to open source projects that stand upon libre and diverse standards.&lt;/p&gt;
&lt;p&gt;Prior to QuantStack I worked as a developer on the PySide team at the Qt Company and as a web performance developer at Mozilla.&lt;/p&gt;
</content><category term="kernels"/></entry><entry><title>Interactive Graph Visualization in Jupyter with ipycytoscape</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/" rel="alternate"/><published>2020-04-30T16:16:00+00:00</published><updated>2020-07-28T08:34:00+00:00</updated><author><name>Mariana Meireles</name></author><id>tag:jasongrout.github.io,2020-04-30:/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/</id><summary type="html">&lt;p&gt;The Jupyter widgets ecosystem offers a broad variety of data visualization tools for exploratory analysis in the notebook. However, we…&lt;/p&gt;
</summary><content type="html">&lt;p&gt;The Jupyter widgets ecosystem offers a broad variety of data visualization tools for exploratory analysis in the notebook. However, we lack a good story for exploratory graph visualization.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://cytoscape.org/"&gt;Cytoscape&lt;/a&gt; is an open-source software platform for visualizing complex networks and integrating these with any type of attribute data. While it comes from the computational biology community, cytoscape is fully-fledged general-purpose tool for graph visualization and analytics. It now includes a modern web front-end (&lt;a href="https://js.cytoscape.org/"&gt;Cytoscape.JS&lt;/a&gt;) which is a great candidate for integration with Project Jupyter. This is the &lt;em&gt;raison d’être&lt;/em&gt; of &lt;strong&gt;ipycytoscape&lt;/strong&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Gene visualization in ipycytoscape" src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/images/001-1_d9UZBB4OB3LXVm7fTHBHaw.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Gene visualization in ipycytoscape&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The goal of ipycytoscape is to enable users of well-established libraries of the Python ecosystem like Pandas, NetworkX, and NumPy, to visualize their graph data in the Jupyter notebook, and enable them modify the visual outcome programmatically or graphically with a simple API and user interface.&lt;/p&gt;
&lt;p&gt;Fortunately, Cytoscape offers a broad enough API that allows ipycytoscape to be a tool that can, in fact, be used to solve any type of problem modeled as a graph. Some examples consist in the development of new chemicals to analyze interactions between substances in the pharmaceutic industry, in security systems to create attack graphs that can be useful to show possible vulnerabilities in systems, modeling human behavior to understand people’s interaction with business or even to understand complex phenomena like the current crisis. Currently, there is an effort to make ipycytoscape an accessible tool for researchers that are trying to find ways to mitigate and understand it, there is more information about this initiative on the COVID OSS Help &lt;a href="https://covid-oss-help.org/"&gt;website&lt;/a&gt; and the discussion is happening in this &lt;a href="https://github.com/covid-19-net/covid-19-community/"&gt;repository&lt;/a&gt; if you’re interested in joining it.&lt;/p&gt;
&lt;h2 id="current-state"&gt;Current state&lt;/h2&gt;
&lt;p&gt;IPycytoscape is part of the PLASMA project (aka in French, Plateforme d’eLearning pour l’Analyse de données Scientifiques MAssives). This project aims at creating an interactive tool to teach computational analysis of massive scientific data. Its first instance, PlasmaBio, is designed for the needs of teachers and students of the &lt;a href="http://www.magisteregenet.univ-paris-diderot.fr/"&gt;European Master of Genetics&lt;/a&gt; at &lt;a href="https://u-paris.fr/"&gt;Université de Paris&lt;/a&gt;. PlasmaBio provides an authentic experience of the actual genomic and bioinformatic analyses performed in research labs. For that purpose, a custom &lt;a href="https://github.com/plasmabio/plasmabio"&gt;JupyterHub-based system&lt;/a&gt; to control many different Jupyter instances is being specially developed by &lt;a href="http://twitter.com/jtpio"&gt;Jeremy Tuloup&lt;/a&gt; at &lt;a href="https://twitter.com/QuantStack"&gt;QuantStack&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this first version of ipycytoscape, there are still some limitations to what you may be able to do, but there are also some extents from the Python world that will just work out of the box for you. ipycytoscape offers integration between Pandas DataFrames and NetworkX, meaning that you can have a graph visualization of the data you already have with minimal or none adjustments and just a few lines of code.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Usage with NetworkX and DataFrame" src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/images/002-1_yRpK3giBa1BLxxnepSE-kg.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Usage with NetworkX and DataFrame&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;ipycytoscape supports all of the built-in CytoscapeJS layouts. This includes the &lt;code&gt;cola&lt;/code&gt;, &lt;code&gt;grid&lt;/code&gt;, &lt;code&gt;breadthfirst&lt;/code&gt;, &lt;code&gt;circular&lt;/code&gt;, &lt;code&gt;concentric&lt;/code&gt; and &lt;a href="https://github.com/dagrejs/dagre"&gt;Dagre&lt;/a&gt; layout as well as the &lt;code&gt;random&lt;/code&gt;, &lt;code&gt;null&lt;/code&gt; or &lt;code&gt;preset&lt;/code&gt; options to build a graph visualization that fits better to your data .Additionally, ipycytoscape also supports the &lt;a href="https://popper.js.org/docs/v2/"&gt;PopperJS&lt;/a&gt; and &lt;a href="https://atomiks.github.io/tippyjs/"&gt;TippyJS&lt;/a&gt; extensions, that allows you to create customizable tips for your nodes and edges .&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="cola, concentric, dagre and grid layouts" src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/images/003-1__7mOQADG9USBa0AY-RZaBw.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;cola, concentric, dagre and grid layouts&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;You can also use a variety of labels for a quick visualization of your nodes’ and edges’ contents.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Labels on nodes" src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/images/004-1_Tx54Yjz5EbF3kUC-u82XaQ.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Labels on nodes&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Like most Jupyter interactive widgets, ipycytoscape relies on the traitlets library to synchronize data between the back-end and the front-end model.&lt;/p&gt;
&lt;p&gt;Unfortunately, traitlets have a limitation when it comes to container objects and other mutable structures, because synchronization is only triggered upon assignment of the container and not when modifying individual elements.&lt;/p&gt;
&lt;p&gt;To work around this limitation, we make use of the excellent &lt;a href="https://github.com/rmorshea/spectate"&gt;Spectate&lt;/a&gt; library by &lt;a href="https://twitter.com/rmorshea"&gt;Ryan Morshead&lt;/a&gt;, which triggers observers upon individual element changes in containers.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Interaction between ipywidgets and ipycytoscape" src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/images/005-1_0l66uLHE51IpGlDLsOf2kw.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Interaction between ipywidgets and ipycytoscape&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h3 id="try-it-online"&gt;Try it online!&lt;/h3&gt;
&lt;p&gt;You can try it without the need of installing anything on your computer just by clicking on the image below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://mybinder.org/v2/gh/QuantStack/ipycytoscape/stable?filepath=examples"&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/images/006-0_-Lcpj92fbL3Zr7N3.webp" alt="https://mybinder.org/v2/gh/QuantStack/ipycytoscape/stable?filepath=examples" loading="lazy" data-body-image=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3 id="installation"&gt;Installation&lt;/h3&gt;
&lt;p&gt;Note that you first need to have Jupyter installed on your computer. You can install &lt;code&gt;ipycytoscape&lt;/code&gt; using pip:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip install ipycytoscape
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or using conda:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;conda install -c conda-forge ipycytoscape
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you use JupyterLab, you would need to install the JupyterLab extension for ipycanvas (this requires nodejs to be installed):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;jupyter&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;labextension&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;@jupyter&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;widgets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;jupyterlab&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;manager&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;jupyter&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;cytoscape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="about-the-author"&gt;About the author&lt;/h2&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2020/interactive-graph-visualization-in-jupyter-with/images/007-1_S-w69baox7Q1D997a5yKNw.webp" alt="" loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;My name is &lt;a href="https://twitter.com/mari_meir"&gt;Mariana Meireles&lt;/a&gt; and I’m a software developer working for &lt;a href="http://quantstack.net/"&gt;QuantStack&lt;/a&gt;. I care deeply about the impacts that technology has in the world and try my best to be the change I want to see by contributing to open source projects that stand upon libre and diverse standards.&lt;/p&gt;
&lt;p&gt;Prior to QuantStack I worked as a developer on the PySide team at the Qt Company and as a web performance developer at Mozilla.&lt;/p&gt;
&lt;p&gt;Currently I’m working on expanding the Jupyter ecosystem with new libraries and functionalities, like an experimental &lt;a href="https://github.com/jupyter-xeus/xeus-sqlite"&gt;SQLite kernel&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="acknowledgements"&gt;&lt;strong&gt;Acknowledgements&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;The development of ipycytoscape at &lt;a href="https://quantstack.net/"&gt;QuantStack&lt;/a&gt; was funded as part of the &lt;a href="https://twitter.com/PlasmaBio"&gt;PLASMA&lt;/a&gt; project, led by &lt;a href="https://twitter.com/CVandiedonck"&gt;Claire Vandiedonck&lt;/a&gt;, &lt;a href="https://twitter.com/pierrepo"&gt;Pierre Poulain&lt;/a&gt;, and &lt;a href="https://twitter.com/SCaburet"&gt;Sandrine Caburet&lt;/a&gt;, associate professors at Université de Paris.&lt;/p&gt;
&lt;p&gt;Sponsors to the PLASMA initiative include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/iledefrance"&gt;Région Île-de-France&lt;/a&gt;, via the “Trophées franciliens de l’innovation numérique dans le supérieur” (&lt;a href="https://www.iledefrance.fr/trophees-franciliens-de-linnovation-numerique-dans-le-superieur-les-laureats-2018"&gt;EdTech 2018&lt;/a&gt;) grant program,&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/Univ_Paris"&gt;Université de Paris&lt;/a&gt;, via the &lt;a href="https://u-paris.fr/en/the-initiative-of-excellence-idex-label/"&gt;Initiative of Excellence (IdEx) Label&lt;/a&gt; and its “inovating teaching” grant program,&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/EURGENEPARIS"&gt;EUR G.E.N.E.&lt;/a&gt;, the graduate school on Genetics and Epigenetics,&lt;/li&gt;
&lt;li&gt;the university training “Création, analyse et valorisation de données biologiques omiques” (&lt;a href="https://omics-school.net/"&gt;DU Omiques&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
</content><category term="visualization"/><category term="widgets"/></entry></feed>