| 1 |
say "Fast forward through some prior work..." |
| 2 |
|
| 3 |
say "Let's assume a student developed an algorithm, using Git." |
| 4 |
run "mkdir code; cd code; git init; touch work; git add work ; git commit -m 'MSc thesis by student A done'; cd .." |
| 5 |
|
| 6 |
say "An another student collected some data, tracked with Git-annex." |
| 7 |
run "mkdir data; cd data; git init; git annex init; echo 'DATA!' > work; git annex add work ; git commit -m 'Data collection by student B done'; cd .." |
| 8 |
|
| 9 |
say "A postdoc performed an analysis with the new algorithm on that data, results tracked with Git-annex." |
| 10 |
|
| 11 |
run "mkdir analysis; cd analysis; git init && git annex init" |
| 12 |
|
| 13 |
say "Git submodules are perfect for versioned tracking of dependencies, code or data." |
| 14 |
run "git submodule add ../code" |
| 15 |
run "git submodule add ../data" |
| 16 |
run "git -C data annex init" |
| 17 |
run "git commit -m 'Add dependencies'" |
| 18 |
|
| 19 |
run "touch work; git add work && git commit -m 'Analysis by postdoc done'; cd .." |
| 20 |
|
| 21 |
say "This happened in the past... Now the students left and the postdocs is on vacation. Time for the PI to write up the paper..." |
| 22 |
|
| 23 |
say "The paper is nothing but a new project that depends on the analysis of the study it will describe." |
| 24 |
run "mkdir paper" |
| 25 |
run "cd paper" |
| 26 |
run "git init" |
| 27 |
run "git submodule add ../analysis study" |
| 28 |
say "Need to remember what the postdoc said: If a repo uses git-annex, need to init it. Does it?" |
| 29 |
run "git -C study branch -a | grep git-annex" |
| 30 |
say "Ok, seems to be" |
| 31 |
run "git -C study annex init" |
| 32 |
run "git commit -m 'Add analysis'" |
| 33 |
|
| 34 |
say "Let Git assemble the entire working tree" |
| 35 |
run "git submodule update --init --recursive" |
| 36 |
|
| 37 |
say "Arrgh, there is a bug in the code, and the postdoc isn't here to work the fix in. But hey, Git is all distributed -- let's apply it right here, so we can move on with the science..." |
| 38 |
run "echo 'fix' >> study/code/work" |
| 39 |
|
| 40 |
say "Quickly commit the fix, so it can be pushed upstream later..." |
| 41 |
run "git add study/code/work" |
| 42 |
|
| 43 |
say "Erm... Needs to happen in the repository that actually contains the file...Need to look up the boundaries..." |
| 44 |
run "git diff --submodule=diff" |
| 45 |
|
| 46 |
say "Ok, let's do this..." |
| 47 |
run "cd study/code" |
| 48 |
run "git add work && git commit -m 'Fix'" |
| 49 |
|
| 50 |
say "Damn, detached HEAD. Need to fix, or it will be difficult to push." |
| 51 |
run "git reset HEAD~1" |
| 52 |
run "git checkout master" |
| 53 |
run "git add work && git commit -m 'Fix'" |
| 54 |
|
| 55 |
say "Still have to commit all the way up...one sec..." |
| 56 |
run "cd .." |
| 57 |
run "git add code && git commit -m 'Fix'" |
| 58 |
run "cd .." |
| 59 |
run "git add study && git commit -m 'Fix'" |
| 60 |
|
| 61 |
say "All fixed and committed, ready to start. Hopefully, there are no more bugs..." |
| 62 |
|
| 63 |
say "Just need to have one quick look at the data. Git-annex will obtain it in no time..." |
| 64 |
run "git annex get study/data/work" |
| 65 |
|
| 66 |
say "Ah, right. Also needs to be done in the repository that actually has the file. I still remember the boundaries...Gotta keep them in mind." |
| 67 |
run "git -C study/data annex get work" |
| 68 |
|
| 69 |
say "Good! Now back to writing!" |
| 70 |
|
| 71 |
|
| 72 |
say "So far the story with Git/Git-annex. Let's see how the exact same looks with DataLad..." |
| 73 |
say "But first clean up..." |
| 74 |
run "cd .." |
| 75 |
run "rm -rf paper" |
| 76 |
|
| 77 |
say "Git-annex protects the files it manages. First a user needs to give enough permissions." |
| 78 |
run "chmod -R u+rwx paper" |
| 79 |
run "rm -rf paper" |
| 80 |
|
| 81 |
say "Now DataLad. We can use the identical repositories for the prior student and postdoc work. DataLad does not require that everyone uses DataLad." |
| 82 |
run "datalad create --no-annex paper" |
| 83 |
run "cd paper" |
| 84 |
|
| 85 |
say "Cloning a dataset INTO a specified (super)dataset makes it a subdataset." |
| 86 |
run "datalad clone --dataset . ../analysis study" |
| 87 |
say "Requesting a particular file automatically obtains all needed subdatasets" |
| 88 |
run "datalad get study/code/work" |
| 89 |
|
| 90 |
say "Apply the code fix, and have it be detected" |
| 91 |
run "echo 'fix' >> study/code/work" |
| 92 |
run "datalad status" |
| 93 |
|
| 94 |
say "Unlike Git, DataLad makes nested datasets feel like a monorepo" |
| 95 |
run "datalad status --recursive" |
| 96 |
|
| 97 |
say "Not just for reporting, but also for modification" |
| 98 |
run "datalad save --dataset . -m 'Fix' study/code/work" |
| 99 |
run "datalad status" |
| 100 |
|
| 101 |
say "All modifications are committed up to a specified superdataset". |
| 102 |
|
| 103 |
say "Requesting an annex'ed files is no different from any other file" |
| 104 |
run "datalad get study/data/work" |
| 105 |
run "cat study/data/work" |
| 106 |
|
| 107 |
say "When done, just remove" |
| 108 |
run "cd .." |
| 109 |
run "datalad remove --dataset paper --recursive" |