Merge branch 'master' into 2257-inequality-conditions
[arvados.git] / doc / user / tutorials / tutorial-keep.html.textile.liquid
1 ---
2 layout: default
3 navsection: userguide
4 title: "Storing and Retrieving data using Keep"
5 ...
6
7 This tutorial introduces you to the Arvados file storage system.
8
9
10 *This tutorial assumes that you are "logged into an Arvados VM instance":{{site.baseurl}}/user/getting_started/ssh-access.html#login, and have a "working environment.":{{site.baseurl}}/user/getting_started/check-environment.html*
11
12 The Arvados distributed file system is called *Keep*.  Keep is a content-addressable file system.  This means that files are managed using special unique identifiers derived from the _contents_ of the file, rather than human-assigned file names (specifically, the md5 hash).  This has a number of advantages:
13 * Files can be stored and replicated across a cluster of servers without requiring a central name server.
14 * Systematic validation of data integrity by both server and client because the checksum is built into the identifier.
15 * Minimizes data duplication (two files with the same contents will result in the same identifier, and will not be stored twice.)
16 * Avoids data race conditions (an identifier always points to the same data.)
17
18 h1. Putting Data into Keep
19
20 We will start with downloading a freely available VCF file from the "Personal Genome Project (PGP)":http://www.personalgenomes.org subject "hu599905":https://my.personalgenomes.org/profile/hu599905 to a staging directory on the VM, and then add it to Keep.
21
22 In the following tutorials, replace <b><code>you</code></b> with your user id.
23
24 First, log into the Arvados VM instance and set up the staging area:
25
26 notextile. <pre><code>~$ <span class="userinput">mkdir /scratch/<b>you</b></span></code></pre>
27
28 Next, download the file:
29
30 <notextile>
31 <pre><code>~$ <span class="userinput">cd /scratch/<b>you</b></span>
32 /scratch/<b>you</b>$ <span class="userinput">curl -o var-GS000016015-ASM.tsv.bz2 'https://warehouse.personalgenomes.org/warehouse/f815ec01d5d2f11cb12874ab2ed50daa+234+K@ant/var-GS000016015-ASM.tsv.bz2'</span>
33   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
34                                  Dload  Upload   Total   Spent    Left  Speed
35 100  216M  100  216M    0     0  10.0M      0  0:00:21  0:00:21 --:--:-- 9361k
36 </code></pre>
37 </notextile>
38
39 {% include 'notebox_begin' %}
40
41 If you have your own data, for example @MyData.vcf@, you can use @scp@ or @rsync@ to copy from your local workstation to the shell VM (run this on your local workstation):
42
43 notextile. <pre><code>~$ <span class="userinput">scp MyData.vcf <b>you@shell</b>.arvados:/scratch/<b>you</b>/MyData.vcf</span></code></pre>
44
45 {% include 'notebox_end' %}
46
47 Now use @arv keep put@ to add your VCF data to Keep, then delete the local copy of the file:
48
49 <notextile>
50 <pre><code>/scratch/<b>you</b>$ <span class="userinput">arv keep put var-GS000016015-ASM.tsv.bz2</span>
51 c1bad4b39ca5a924e481008009d94e32+210
52 /scratch/<b>you</b>$ <span class="userinput">rm var-GS000016015-ASM.tsv.bz2</span>
53 </code></pre>
54 </notextile>
55
56 The output value @c1bad4b39ca5a924e481008009d94e32+210@ from @arv keep put@ is the Keep locator.  This enables you to access the file you just uploaded, and is explained in the next section.
57
58 h2(#dir). Putting a directory
59
60 You can also use @arv keep put@ to add an entire directory:
61
62 <notextile>
63 <pre><code>/scratch/<b>you</b>$ <span class="userinput">mkdir tmp</span>
64 /scratch/<b>you</b>$ <span class="userinput">echo "hello alice" > tmp/alice.txt</span>
65 /scratch/<b>you</b>$ <span class="userinput">echo "hello bob" > tmp/bob.txt</span>
66 /scratch/<b>you</b>$ <span class="userinput">echo "hello carol" > tmp/carol.txt</span>
67 /scratch/<b>you</b>$ <span class="userinput">arv keep put tmp</span>
68 0M / 0M 100.0% 
69 887cd41e9c613463eab2f0d885c6dd96+83
70 </code></pre>
71 </notextile>
72
73 The locator @887cd41e9c613463eab2f0d885c6dd96+83@ represents a collection with multiple files.
74
75 h1. Getting Data from Keep
76
77 h2. Using Workbench
78
79 You may access collections through the "Collections section of Arvados Workbench":https://{{ site.arvados_workbench_host }}/collections located at "https://{{ site.arvados_workbench_host }}/collections":https://{{ site.arvados_workbench_host }}/collections .  You can also access individual collections and individual files within a collection.  Some examples:
80
81 * "https://{{ site.arvados_workbench_host }}/collections/c1bad4b39ca5a924e481008009d94e32+210":https://{{ site.arvados_workbench_host }}/collections/c1bad4b39ca5a924e481008009d94e32+210
82 * "https://{{ site.arvados_workbench_host }}/collections/887cd41e9c613463eab2f0d885c6dd96+83/alice.txt":https://{{ site.arvados_workbench_host }}/collections/887cd41e9c613463eab2f0d885c6dd96+83/alice.txt
83
84 h2(#arv-get). Using arv-get
85
86 You can view the contents of a collection using @arv keep ls@:
87
88 <notextile>
89 <pre><code>/scratch/<b>you</b>$ <span class="userinput">arv keep ls c1bad4b39ca5a924e481008009d94e32+210</span>
90 var-GS000016015-ASM.tsv.bz2
91 </code></pre>
92
93 <pre><code>/scratch/<b>you</b>$ <span class="userinput">arv keep ls 887cd41e9c613463eab2f0d885c6dd96+83</span>
94 alice.txt
95 bob.txt
96 carol.txt
97 </code></pre>
98 </notextile>
99
100 Use @-s@ to print file sizes rounded up to the nearest kilobyte:
101
102 <notextile>
103 <pre><code>/scratch/<b>you</b>$ <span class="userinput">arv keep ls -s c1bad4b39ca5a924e481008009d94e32+210</span>
104 221887 var-GS000016015-ASM.tsv.bz2
105 </code></pre>
106 </notextile>
107
108 Use @arv keep get@ to download the contents of a collection and place it in the directory specified in the second argument (in this example, @.@ for the current directory):
109
110 <notextile>
111 <pre><code>/scratch/<b>you</b>$ <span class="userinput">arv keep get c1bad4b39ca5a924e481008009d94e32+210/ .</span>
112 </code></pre>
113 </notextile>
114
115 You can also download indvidual files:
116
117 <notextile>
118 <pre><code>/scratch/<b>you</b>$ <span class="userinput">arv keep get 887cd41e9c613463eab2f0d885c6dd96+83/alice.txt .</span>
119 </code></pre>
120 </notextile>
121
122 With a local copy of the file, we can do some computation, for example computing the md5 hash of the complete file:
123
124 <notextile>
125 <pre><code>/scratch/<b>you</b>$ <span class="userinput">md5sum var-GS000016015-ASM.tsv.bz2</span>
126 44b8ae3fde7a8a88d2f7ebd237625b4f  var-GS000016015-ASM.tsv.bz2
127 </code></pre>
128 </notextile>
129
130 h2. Using arv-mount
131
132 Use @arv-mount@ to take advantage of the "File System in User Space / FUSE":http://fuse.sourceforge.net/ feature of the Linux kernel to mount a Keep collection as if it were a regular directory tree.
133
134 <notextile>
135 <pre><code>/scratch/<b>you</b>$ <span class="userinput">mkdir mnt</span>
136 /scratch/<b>you</b>$ <span class="userinput">arv-mount --collection c1bad4b39ca5a924e481008009d94e32+210 mnt &</span>
137 /scratch/<b>you</b>$ <span class="userinput">cd mnt</span>
138 /scratch/<b>you</b>/mnt$ <span class="userinput">ls</span>
139 var-GS000016015-ASM.tsv.bz2
140 /scratch/<b>you</b>/mnt$ <span class="userinput">md5sum var-GS000016015-ASM.tsv.bz2</span>
141 44b8ae3fde7a8a88d2f7ebd237625b4f  var-GS000016015-ASM.tsv.bz2
142 /scratch/<b>you</b>/mnt$ <span class="userinput">cd ..</span>
143 /scratch/<b>you</b>$ <span class="userinput">fusermount -u mnt</span>
144 </code></pre>
145 </notextile>
146
147 You can also mount the entire Keep namespace in "magic directory" mode:
148
149 <notextile>
150 <pre><code>/scratch/<b>you</b>$ <span class="userinput">mkdir mnt</span>
151 /scratch/<b>you</b>$ <span class="userinput">arv-mount mnt &</span>
152 /scratch/<b>you</b>$ <span class="userinput">cd mnt/c1bad4b39ca5a924e481008009d94e32+210</span>
153 /scratch/<b>you</b>/mnt/c1bad4b39ca5a924e481008009d94e32+210$ <span class="userinput">ls</span>
154 var-GS000016015-ASM.tsv.bz2
155 /scratch/<b>you</b>/mnt/c1bad4b39ca5a924e481008009d94e32+210$ <span class="userinput">md5sum var-GS000016015-ASM.tsv.bz2</span>
156 44b8ae3fde7a8a88d2f7ebd237625b4f  var-GS000016015-ASM.tsv.bz2
157 /scratch/<b>you</b>/mnt/c1bad4b39ca5a924e481008009d94e32+210$ <span class="userinput">cd ../..</span>
158 /scratch/<b>you</b>$ <span class="userinput">fusermount -u mnt</span>
159 </code></pre>
160 </notextile>
161
162 Using @arv-mount@ has several significant benefits:
163
164 * You can browse, open and read Keep entries as if they are regular files.
165 * It is easy for existing tools to access files in Keep.
166 * Data is downloaded on demand, it is not necessary to download an entire file or collection to start processing