Data safety

Later in the day, after seeing and solving so many DataLad error messages, you fall tired into your bed. Just as you are about to fall asleep, a thought crosses your mind:

“I now know that tracked content in a dataset is protected by Git-annex. Whenever tracked contents are saved, they get locked and should not be modifiable. But… what about the notes that I have been taking since the first day? Should I not need to unlock them before I can modify them? And also the script! I was able to modify this despite giving it to DataLad to track, with no permission denied errors whatsoever! How does that work?”

This night, though, your question stays unanswered and you fall into a restless sleep filled with bad dreams about “permission denied” errors. The next day you’re the first student in your lecturer’s office hours.

“Oh, you’re really attentive. This is a great question!” our lecturer starts to explain.

Do you remember that we created the DataLad-101 dataset with a specific configuration template? It was the -c text2git option we provided in the beginning of Create a dataset. It is because of this configuration that we can modify notes.txt without unlocking its content first.

The second commit message in our datasets history summarizes this:

$ git log --reverse --oneline
e85b950 [DATALAD] new dataset
1a45fd4 Instruct annex to add text files to Git
9a6fb63 add books on Python and Unix to read later
dac2fa7 add reference book about git
b72b237 Add notes on datalad create
5f98f2b add note on datalad save
49e85d1 [DATALAD] Recorded changes
e61c229 Add note on datalad install
ef8b726 Add simple script to write a list of podcast speakers and titles
ecde4e4 [DATALAD RUNCMD] create a list of podcast titles
d04c4af BF: list both directories content
d26a29b [DATALAD RUNCMD] create a list of podcast titles
4e3fb6e add note datalad and git diff
327fd83 add note on basic datalad run and datalad rerun
6e624f5 [DATALAD RUNCMD] convert -resize 400x400 recordings/longn...
257130b resized picture by hand
e3277e9 [DATALAD RUNCMD] convert -resize 450x450 recordings/longn...
244c234 add additional notes on run options
36a9cfd [DATALAD RUNCMD] Resize logo for slides
d9d0872 [DATALAD RUNCMD] Resize logo for slides
dd6fef5 add note on clean datasets

Instead of giving text files such as your notes or your script to Git-annex, the dataset stores it in Git. But what does it mean if files are in Git instead of Git-annex?

Well, procedurally it means that everything that is stored in Git-annex is content-locked, and everything that is stored in Git is not. You can modify content stored in Git straight away, without unlocking it first.

A simplified illustration of content lock in files managed by Git-annex.

Fig. 5 A simplified overview of the tools that manage data in your dataset.

That’s easy enough.

“So, first of all: If we hadn’t provided the -c text2git argument, text files would get content-locked, too?”. “Yes, indeed. However, there are also ways to later change how file content is handled based on its type or size. It can be specified in the .gitattributes file, using annex.largefile options. But there will be a lecture on that1.”

“Okay, well, second: Isn’t it much easier to just not bother with locking and unlocking, and have everything ‘stored in Git’? Even if datalad run takes care of unlocking content, I do not see the point of Git-annex”, you continue.

Here it gets tricky. To begin with the most important, and most straight-forward fact: It is not possible to store large files in Git. This is because Git would very quickly run into severe performance issues. For this reason, Github, a well-known hosting site for projects using Git, for example does not allow files larger than 100MB of size.

For now, we have solved the mystery of why text files can be modified without unlocking, and this is a small improvement in the vast amount of questions that have piled up in our curious minds. Essentially, Git-annex protects your data from accidental modifications and thus keeps it safe. datalad run commands mitigate any technical complexity of this completely if -o/--output is specified properly, and datalad unlock commands can be used to unlock content “by hand” if modifications are performed outside of a datalad run.

But there comes the second, tricky part: There are ways to get rid of locking and unlocking within Git-annex, using so-called adjusted branches. This functionality is dependent on the Git-annex version one has installed, the Git-annex version of the repository, and a use-case dependent comparison of the pros and cons. BUT: it is possible, and in many cases useful, and in later sections we will see how to use this feature. The next lecture, in any way, will guide us deeper into Git-annex, and improve our understanding a slight bit further.

Footnotes

1

If you can’t wait to read about .gitattributes and other configuration files, jump ahead to chapter “Tuning datasets to your needs”, starting with section DIY configurations.