<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>ProvBook: Provenance-based Semantic Enrichment of Interactive Notebooks for Reproducibility</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Sheeba Samuel</string-name>
          <email>sheeba.samuel@uni-jena.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Birgitta Konig-Ries</string-name>
          <email>birgitta.koenig-ries@uni-jena.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Heinz-Nixdorf Chair for Distributed Information Systems Friedrich-Schiller University</institution>
          ,
          <addr-line>Jena</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>With the rapid growth of data science and machine learning, interactive notebooks have gained widespread adoption among scientists across all disciplines to publish their computational experiments containing code, text, and results. As it is easy to modify and re-run the computations in a notebook, it is important to know how the provenance of results changed in di erent executions over the course of time, thus enabling trust and reproducibility. In this paper, we present ProvBook, an extension of Jupyter Notebook to capture and view the provenance over the course of time. It also allows the user to share a notebook along with its provenance in RDF and also convert it back to a notebook. We use the REPRODUCE-ME ontology extended from PROV-O and PPlan to describe the provenance of a notebook. This helps the scientists to compare their previous results with the current ones, check whether the experiments produce the results as expected and query the sequence of executions using SPARQL. The notebook data in RDF can be used in combination with the experiments that used them and help to get a track of the complete path of the scienti c experiments.</p>
      </abstract>
      <kwd-group>
        <kwd>Notebooks</kwd>
        <kwd>Provenance</kwd>
        <kwd>Reproducibility</kwd>
        <kwd>RDF</kwd>
        <kwd>Ontology</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        The Jupyter Notebook [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] is an open-source web application to create documents
with interactive output and supports over 40 programming languages with
millions of users. Notebook documents contain blocks of text and code organized as
cells. The code cells contain code snippets which can be modi ed and executed
individually and the output is displayed directly below the cell. The markdown
cells contain documentation of the computational processes. The cells are
arranged linearly but can be moved or executed in any order. The notebook can
be shared in di erent formats including HTML, PDF, and LaTeX.
Rule et al. [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] present a study in which they analyzed over 1 million publicly
available notebooks and interviewed 15 data scientists from di erent disciplines.
One of their results highlights the need for tracking provenance especially when
the cells are over-written and re-run. Provenance tracking is largely helpful in
the trial and error experiments where it is essential to understand how exactly
a nal result has been achieved. It is also necessary to keep track of the
experiments that have been attempted because that may bene t other scientists, even
if the results are not as expected. Pimentel et al. [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] present a mechanism to
capture and analyze provenance of python scripts inside IPythonNotebooks by
integrating with noWork ow [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. PROV-O-Matic1 is another provenance-tracking
extension for older versions of IPython Notebooks which saves the provenance
traces to Linked Data le using PROV-O. Another recent approach is to
convert notebooks into work ows where notebook developers need to follow a set
of guidelines in writing code [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. These approaches have the limitation that they
require changes to scripts by the user and are limited to Python scripts. In our
approach, the provenance tracking is integrated within a notebook so there is no
need to change the scripts and learn a new tool. It is also easy to share the
notebook along with the provenance traces of execution described as Linked Data.
We developed ProvBook2, an extension of Jupyter Notebook to capture and
track the provenance of the cells over the course of the time. Every time the
code cell is executed, the provenance of the run is stored in the metadata of the
cell in the notebook. The provenance data of a code cell includes the start and
1 https://github.com/Data2Semantics/prov-o-matic
2 https://github.com/Sheeba-Samuel/ProvBook
end time of the execution, the total time it took to run the cell, the source and
the output of the cell. It also allows the user to see the changes and the modi ed
time of the text of a markdown cell whenever a notebook is saved. Figure. 1
shows the provenance of a code cell along with its input and output. When the
extension is enabled, the visualization of the provenance data is displayed below
the input of every cell. The user can view the history over the course of time
by moving the slider. In this way, the user can compare the previous results
with the current ones and see the di erence that occurred. The user has the
option to view the provenance of selected or all cells as well as clear them if
needed. ProvBook also provides the user the ability to convert the notebooks
to RDF. In our previous work [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], we have shown how we combined the P-Plan
[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] and the REPRODUCE-ME [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] ontology extended from PROV-O [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] to
describe the interactive notebooks along with the experiments which used them in
a multi-user environment provided by JupyterHub. The metadata of the
notebook fetched from JupyterHub API was stored along with the experimental data
in a relational database and displayed in the project dashboard of our prototype.
We extend our work by providing an extension to download the notebook as a
Turtle document so that it is easy to share with the collaborators. The RDF
le can also be converted back to the notebook for easy reading and
execution. Figure. 2 shows how the provenance of the notebook is represented using
xsd:string
prov:Entity
REPRODUCE-ME
P-Plan
PROV-O
xsd:dateTime
      </p>
      <p>prov:endedAtTime
xsd:dateTime
executionTime</p>
      <p>prov:Entity
prov:used
prov:generated
p-plan:Activity
prov:startedAtTime
rdf:type</p>
      <p>prov:Agent</p>
      <p>CellExecution
p-plan:correspondsToStep
prov:wasAttributedTo
p-plan:Step rdf:type Cell
p-plan:isStepOfPlan</p>
      <p>Notebook
rdf:type
p-plan:Plan
p-plan:hasInputVar</p>
      <p>Source
p-plan:hasOutputVar</p>
      <p>Output
hasKernel
Kernel
hasProgrammingLanguage</p>
      <p>ProgrammingLanguage
rdf:type</p>
      <p>rdf:type
p-plan:Variable
rdf:type</p>
      <p>rdf:type
Setting
hasVersion</p>
      <p>Version
the REPRODUCE-ME ontology. The notebook is described as a p plan:P lan
with the cells as p plan:Step of the plan. Every run of a cell is represented
as CellExecution, which is a subclass of p plan:Activity. The CellExecution
uses input and generates output with start and end time. The notebook is
attributed to the authors using the object property prov:wasAttributedT o. The
provenance information including the kernel, programming language, and its
version is available in the downloaded version of RDF. The ProvBook was evaluated
with around 50 publicly available notebooks.
3</p>
      <p>Demonstration Overview
We will demonstrate the working of ProvBook where the participants will be
able to load or author notebooks, execute them and check the provenance of
results. They will also be able to convert the notebooks to RDF and import
them back to notebooks. We would also like to invite the participants to use
their own notebooks with ProvBook. A video showing the installation and use
of ProvBook with an example is available at https://doi.org/10.6084/m9.
figshare.6401096.</p>
      <p>Acknowledgements
This research is supported by the Deutsche Forschungsgemeinschaft (DFG) in
Project Z2 of the CRC/TRR 166 High-end light microscopy elucidates membrane
receptor function - ReceptorLight.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Carvalho</surname>
            ,
            <given-names>L.A.M.C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gil</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Garijo</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          : Niw:
          <article-title>Converting notebooks into work ows to capture data ow and provenance (</article-title>
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Garijo</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gil</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          :
          <article-title>Augmenting PROV with plans in P-Plan: scienti c processes as linked data</article-title>
          .
          <source>CEUR Workshop Proceedings</source>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Kluyver</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ragan-Kelley</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          , et al.:
          <article-title>Jupyter notebooks-a publishing format for reproducible computational work ows</article-title>
          .
          <source>In: ELPUB</source>
          . pp.
          <volume>87</volume>
          {
          <issue>90</issue>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Lebo</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sahoo</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>McGuinness</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Belhajjame</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          , et al.:
          <string-name>
            <surname>PROV-O: The PROV</surname>
          </string-name>
          <article-title>Ontology</article-title>
          .
          <source>W3C Recommendation</source>
          <volume>30</volume>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Pimentel</surname>
            ,
            <given-names>J.a.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Murta</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Braganholo</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Freire</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>noWork ow: A tool for collecting, analyzing, and managing provenance from python scripts</article-title>
          .
          <source>Proc. VLDB Endow</source>
          .
          <volume>10</volume>
          (
          <issue>12</issue>
          ),
          <year>1841</year>
          {1844 (Aug
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Pimentel</surname>
            ,
            <given-names>J.F.N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Braganholo</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Murta</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Freire</surname>
          </string-name>
          , J.:
          <article-title>Collecting and analyzing provenance on interactive notebooks: When IPython meets noWork ow</article-title>
          .
          <source>In: 7th USENIX Workshop on the Theory and Practice of Provenance (TaPP 15)</source>
          . USENIX Association, Edinburgh, Scotland (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Rule</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tabard</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hollan</surname>
            ,
            <given-names>J.D.</given-names>
          </string-name>
          :
          <article-title>Exploration and explanation in computational notebooks</article-title>
          .
          <source>In: Proceedings of the 2018 CHI Conference on Human Factors in Computing Systems</source>
          . pp.
          <volume>32</volume>
          :
          <issue>1</issue>
          {
          <fpage>32</fpage>
          :
          <fpage>12</fpage>
          . CHI '18,
          <string-name>
            <surname>ACM</surname>
          </string-name>
          , New York, NY, USA (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Samuel</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <article-title>Konig-</article-title>
          <string-name>
            <surname>Ries</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>REPRODUCE-ME: ontology-based data access for reproducibility of microscopy experiments</article-title>
          . In: The Semantic Web:
          <article-title>ESWC 2017 Satellite Events</article-title>
          , Portoroz, Slovenia. pp.
          <volume>17</volume>
          {
          <issue>20</issue>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Samuel</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <article-title>Konig-</article-title>
          <string-name>
            <surname>Ries</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Combining p-plan and the reproduce-me ontology to achieve semantic enrichment of scienti c experiments using interactive notebooks</article-title>
          .
          <source>In: The Semantic Web: ESWC 2018 Satellite Events</source>
          . pp.
          <volume>126</volume>
          {
          <issue>130</issue>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>