What DataLad adds to Git/git-annex?


xkcd comic 1597

What makes scientific workflows special?

Scientific building blocks are not static.
Version control beyond text
Science is build from modular units.
Nesting
Science is exploratory, iterative, multi-stepped, and complex.
Provenance
Science is collaborative.
Transport logistics

A simpler core API

  • Example: Add a new file into a dataset
  • # create a data analysis script
    $ datalad status
    untracked: code/script.py (file)
    $ git status
    On branch master
    Untracked files:
      (use "git add file..." to include in what will be committed)
    	code/script.py
    
    nothing added to commit but untracked files present (use "git add" to track)
        
    # create a data analysis script
    $ datalad status
    untracked: code/script.py (file)
    $ git status
    On branch master
    Untracked files:
      (use "git add file..." to include in what will be committed)
    	code/script.py
    
    nothing added to commit but untracked files present (use "git add" to track)
        

  • Save the dataset modification...
    • ... with DataLad
    • $ datalad save \
          -m "Add a k-nearest-neighbour clustering analysis" \
          code/script.py 
    • ... versus with Git
    • $ git add code/script.py
      $ git commit -m "Add a k-nearest-neighbour clustering analysis"
    • ... versus with git-annex
    • $ git annex add code/script.py
      $ git commit -m "Add a k-nearest-neighbour clustering analysis"

Git submodules

  • Built-in Git feature: Add a repository to another repository, treating them as separate projects (e.g., use third party project, but keep commits separate)
Make a project with a submodule:
$ git init myproject
Initialized empty Git repository in /tmp/myproject/.git/
$ cd myproject
$ git submodule add \
    https://github.com/adswa/multimatch_gaze.git
Cloning into '/tmp/myproject/multimatch_gaze'...
done.
$ git commit -am 'Add multimatch module'
[main fb9093c] Add multimatch module
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 multimatch_gaze
         
Get a repository with a submodule:
$ git clone https://github.com/adswa/myproject.git
Cloning into 'myproject'...
done.
$ cd myproject
$ git submodule init
Submodule 'multimatch_gaze' (https://github.com/adswa/multimatch_gaze.git)
registered for path 'multimatch_gaze'

DataLad subdatasets

  • DataLad simplifies submodule mechanism with superdataset-subdataset hierarchies:

  • $ cd myanalysis
    # we can install analysis input data as a subdataset to the dataset
    $ datalad clone -d . https://github.com/datalad-handbook/iris_data.git input/
    [INFO   ] Scanning for unlocked files (this may take some time)
    [INFO   ] Remote origin not usable by git-annex; setting annex-ignore
    install(ok): input (dataset)
    add(ok): input (file)
    add(ok): .gitmodules (file)
    save(ok): . (dataset)
    action summary:
      add (ok: 2)
      install (ok: 1)
      save (ok: 1)
    

    data analysis provenance

    Enshrine the analysis in a script

    Here: extract_lc_timeseries.py

    $ datalad containers-run \
      --message "Time series extraction from Locus Coeruleus"
      --container-name nilearn \
      --input 'mri/*_bold.nii' \
      --output 'sub-*/LC_timeseries_run-*.csv' \
      "python3 code/extract_lc_timeseries.py"
    
    -- Git commit --
        commit 5a7565a640ff6de67e07292a26bf272f1ee4b00e
        Author:     Adina Wagner adina.wagner@t-online.de
        AuthorDate: Mon Nov 11 16:15:08 2019 +0100
        Commit:     Adina Wagner adina.wagner@t-online.de
        CommitDate: Mon Nov 11 16:15:08 2019 +0100
    
        [DATALAD RUNCMD] Time series extraction from Locus Coeruleus
        === Do not change lines below ===
        {
         "cmd": "singularity exec --bind {pwd} .datalad/environments/nilearn.simg bash..",
         "dsid": "92ea1faa-632a-11e8-af29-a0369f7c647e",
         "inputs": [
          "mri/*.bold.nii.gz",
          ".datalad/environments/nilearn.simg"
         ],
         "outputs": ["sub-*/LC_timeseries_run-*.csv"],
         ...
        }
        ^^^ Do not change lines above ^^^
    ---
     sub-01/LC_timeseries_run-1.csv | 1 +
    ...
    

    data analysis provenance

    Record code execution together
    with input-data, output files and software environment in the execution-command

    $ datalad containers-run \
      --message "Time series extraction from Locus Coeruleus"
      --container-name nilearn \
      --input 'mri/*_bold.nii' \
      --output 'sub-*/LC_timeseries_run-*.csv' \
      "python3 code/extract_lc_timeseries.py"
    
    -- Git commit --
        commit 5a7565a640ff6de67e07292a26bf272f1ee4b00e
        Author:     Adina Wagner adina.wagner@t-online.de
        AuthorDate: Mon Nov 11 16:15:08 2019 +0100
        Commit:     Adina Wagner adina.wagner@t-online.de
        CommitDate: Mon Nov 11 16:15:08 2019 +0100
    
        [DATALAD RUNCMD] Time series extraction from Locus Coeruleus
        === Do not change lines below ===
        {
         "cmd": "singularity exec --bind {pwd} .datalad/environments/nilearn.simg bash..",
         "dsid": "92ea1faa-632a-11e8-af29-a0369f7c647e",
         "inputs": [
          "mri/*.bold.nii.gz",
          ".datalad/environments/nilearn.simg"
         ],
         "outputs": ["sub-*/LC_timeseries_run-*.csv"],
         ...
        }
        ^^^ Do not change lines above ^^^
    ---
     sub-01/LC_timeseries_run-1.csv | 1 +
    ...
    

    data analysis provenance

    Result: machine readable record about which data, code, and
    software produced a result how, when, and why.

    $ datalad containers-run \
      --message "Time series extraction from Locus Coeruleus"
      --container-name nilearn \
      --input 'mri/*_bold.nii' \
      --output 'sub-*/LC_timeseries_run-*.csv' \
      "python3 code/extract_lc_timeseries.py"
    
    -- Git commit --
        commit 5a7565a640ff6de67e07292a26bf272f1ee4b00e
        Author:     Adina Wagner adina.wagner@t-online.de
        AuthorDate: Mon Nov 11 16:15:08 2019 +0100
        Commit:     Adina Wagner adina.wagner@t-online.de
        CommitDate: Mon Nov 11 16:15:08 2019 +0100
    
        [DATALAD RUNCMD] Time series extraction from Locus Coeruleus
        === Do not change lines below ===
        {
         "cmd": "singularity exec --bind {pwd} .datalad/environments/nilearn.simg bash..",
         "dsid": "92ea1faa-632a-11e8-af29-a0369f7c647e",
         "inputs": [
          "mri/*.bold.nii.gz",
          ".datalad/environments/nilearn.simg"
         ],
         "outputs": ["sub-*/LC_timeseries_run-*.csv"],
         ...
        }
        ^^^ Do not change lines above ^^^
    ---
     sub-01/LC_timeseries_run-1.csv | 1 +
    ...
    

    data analysis provenance

    Use the unique identifier of the execution record

    $ datalad rerun 5a7565a640ff6de67
    [INFO   ] run commit 5a7565a640ff6de67; (Time series extraction from Locus Coeruleus)
    [INFO   ] Making sure inputs are available (this may take some time)
    get(ok): mri/sub-01_bold.nii (file)
    get(ok): mri/sub-02_bold.nii (file)
            [...]
    [INFO   ] == Command start (output follows) =====
    [INFO   ] == Command exit (modification check follows) =====
    add(ok): sub-01/LC_timeseries_run-*.csv(file)
    add(ok): sub-02/LC_timeseries_run-*.csv (file)
            [...]
    action summary:
      add (ok: 30)
      get (ok: 30)
      save (ok: 2)
      unlock (ok: 30)
        

    data analysis provenance

    ... to have a machine recompute and verify past work

    $ datalad rerun 5a7565a640ff6de67
    [INFO   ] run commit 5a7565a640ff6de67; (Time series extraction from Locus Coeruleus)
    [INFO   ] Making sure inputs are available (this may take some time)
    get(ok): mri/sub-01_bold.nii (file)
    get(ok): mri/sub-02_bold.nii (file)
            [...]
    [INFO   ] == Command start (output follows) =====
    [INFO   ] == Command exit (modification check follows) =====
    add(ok): sub-01/LC_timeseries_run-*.csv(file)
    add(ok): sub-02/LC_timeseries_run-*.csv (file)
            [...]
    action summary:
      add (ok: 30)
      get (ok: 30)
      save (ok: 2)
      unlock (ok: 30)
        

    Interoperability

    • Scientific workflows can be idiosyncratic across institutions / departments / labs / any two scientists

    Interoperability

    • DataLad is built to maximize interoperability and streamline routines across hosting and storage technology