-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.html
380 lines (380 loc) · 51.7 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang xml:lang>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>README</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
background-color: #2a211c;
color: #bdae9d;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #bdae9d; padding-left: 4px; }
div.sourceCode
{ color: #bdae9d; background-color: #2a211c; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ffff00; } /* Alert */
code span.an { color: #0066ff; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { } /* Attribute */
code span.bn { color: #44aa43; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #43a8ed; font-weight: bold; } /* ControlFlow */
code span.ch { color: #049b0a; } /* Char */
code span.cn { } /* Constant */
code span.co { color: #0066ff; font-weight: bold; font-style: italic; } /* Comment */
code span.do { color: #0066ff; font-style: italic; } /* Documentation */
code span.dt { text-decoration: underline; } /* DataType */
code span.dv { color: #44aa43; } /* DecVal */
code span.er { color: #ffff00; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #44aa43; } /* Float */
code span.fu { color: #ff9358; font-weight: bold; } /* Function */
code span.im { } /* Import */
code span.in { color: #0066ff; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #43a8ed; font-weight: bold; } /* Keyword */
code span.op { } /* Operator */
code span.pp { font-weight: bold; } /* Preprocessor */
code span.sc { color: #049b0a; } /* SpecialChar */
code span.ss { color: #049b0a; } /* SpecialString */
code span.st { color: #049b0a; } /* String */
code span.va { } /* Variable */
code span.vs { color: #049b0a; } /* VerbatimString */
code span.wa { color: #ffff00; font-weight: bold; } /* Warning */
</style>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
<style>
body {
max-width: 60em
}
</style>
</head>
<body>
<h1 id="intro-to-viash">Intro to viash</h1>
<p>Data Intuitive Tuesday - January 26, 2021</p>
<ul>
<li><a href="#installing-viash">Installing viash</a></li>
<li><a href="#example-1-a-minimal-viash-config-file">Example 1: a minimal viash config file</a></li>
<li><a href="#example-2-adding-some-arguments">Example 2: adding some arguments</a></li>
<li><a href="#example-3-setting-different-argument-types">Example 3: setting different argument types</a></li>
<li><a href="#example-4-adding-documentation">Example 4: adding documentation</a></li>
<li><a href="#example-4-part-2-building-an-executable">Example 4 part 2: building an <em>executable</em></a></li>
<li><a href="#example-5-wrapping-a-script">Example 5: Wrapping a script</a></li>
<li><a href="#example-6-running-the-component-inside-a-docker-container">Example 6: running the component inside a Docker container</a></li>
</ul>
<p>A step in the rendering of the video contains of one aspect that can be considered on its own. Understanding the logic of a step, however, is not sufficient as we have seen before. We also need to define the environment in which the step has to be performed.</p>
<p>In other words, we need to understand <em>what</em> needs to run and <em>how</em> it should run. <code>combine_plots</code>, for instance, takes as input a number of plots (<code>png</code> images) and combines them into a plot. As introduced earlier, we can use <code>ffmpeg</code> for this and it’s then just a matter of getting the proper arguments for the tool right. That’s basically what we did in the previous section. But it did not stop there, we had to explicitly install the tool in order to run it. <a href="https://github.com/data-intuitive/viash">viash</a> allows to do exactly this: specify the <em>what</em> and the <em>how</em>.</p>
<p>Before actually porting the Civilization postgame scripts to viash, let’s first look at some small examples to gradually demonstrate how <a href="https://github.com/data-intuitive/viash">viash</a> works. Let’s start by installing the latest release of <a href="https://github.com/data-intuitive/viash">viash</a>!</p>
<h2 id="installing-viash">Installing viash</h2>
<p>Installation of <a href="https://github.com/data-intuitive/viash">viash</a> is explained in <a href="http://www.data-intuitive.com/viash_docs/getting_started/installation/">here</a>.</p>
<p>Since we want to keep this tutorial self-contained, we will download and install the latest (binary) release and install it locally. You’ll need the following for htis:</p>
<ul>
<li>Access to a Linux, UNIX, Mac system or Windows with WSL(2)</li>
<li>A terminal application with a Bash shell</li>
<li>Java 8 or higher installed</li>
</ul>
<p>You can install <a href="https://github.com/data-intuitive/viash">viash</a> for your current user by downloading it and placing it in the ‘bin’ directory in your home folder.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true"></a><span class="fu">mkdir</span> -p ~/bin/</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true"></a><span class="fu">wget</span> https://github.com/data-intuitive/viash/releases/download/v0.3.2/viash -qO ~/bin/viash</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true"></a><span class="fu">chmod</span> +x ~/bin/viash</span></code></pre></div>
<p>If <a href="https://github.com/data-intuitive/viash">viash</a> is installed correctly, you should be able to invoke the help message by executing the following:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> -h</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true"></a><span class="ex">viash</span> 0.3.2 (c) <span class="ex">2020</span> Data Intuitive</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true"></a><span class="ex">viash</span> is a spec and a tool for defining execution contexts and converting execution instructions to concrete instantiations.</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true"></a></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true"></a><span class="ex">This</span> program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. For more information, see our license at the link below.</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true"></a> <span class="ex">https</span>://github.com/data-intuitive/viash/blob/master/LICENSE.md</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true"></a></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true"></a><span class="ex">Usage</span>:</span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true"></a> <span class="ex">viash</span> run config.vsh.yaml -- [arguments for script]</span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true"></a> <span class="ex">viash</span> build config.vsh.yaml</span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true"></a> <span class="ex">viash</span> test config.vsh.yaml</span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true"></a> <span class="ex">viash</span> ns build</span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true"></a> <span class="ex">viash</span> ns test</span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true"></a></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true"></a><span class="ex">Check</span> the help of a subcommand for more information, or the API available at:</span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true"></a> <span class="ex">https</span>://www.data-intuitive.com/viash_docs</span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true"></a></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true"></a><span class="ex">Arguments</span>:</span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true"></a> <span class="ex">-h</span>, --help Show help message</span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true"></a> <span class="ex">-v</span>, --version Show version of this program</span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true"></a></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true"></a><span class="ex">Subcommands</span>:</span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true"></a> <span class="ex">run</span></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true"></a> <span class="ex">build</span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true"></a> <span class="bu">test</span></span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true"></a> <span class="ex">ns</span></span></code></pre></div>
<h2 id="example-1-a-minimal-viash-config-file">Example 1: a minimal viash config file</h2>
<p>A core concept in <a href="https://github.com/data-intuitive/viash">viash</a> is the <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a>, which is a YAML file containing information on software component, such as its parameters, its requirements, and some documentation.</p>
<p>Let us start with the smallest possible <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a>, which is an almost trivial wrapper around <code>ls</code>. <code>ls</code> is a Unix command used to list all files in a directory.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode yaml"><code class="sourceCode yaml"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true"></a><span class="fu">functionality</span><span class="kw">:</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true"></a><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> intro_example1</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true"></a><span class="at"> </span><span class="fu">resources</span><span class="kw">:</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> executable</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true"></a><span class="at"> </span><span class="fu">path</span><span class="kw">:</span><span class="at"> ls</span></span></code></pre></div>
<p><a href="https://www.data-intuitive.com/viash_docs/commands/run"><code>viash run</code></a> is a command for running a component as defined by the <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a>. You can run it as follows:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> run src/intro_example1.vsh.yaml</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true"></a><span class="ex">bin</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true"></a><span class="ex">Makefile</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true"></a><span class="ex">README.html</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true"></a><span class="ex">README.md</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true"></a><span class="ex">README.pdf</span></span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true"></a><span class="ex">README.Rmd</span></span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true"></a><span class="ex">src</span></span></code></pre></div>
<p>Perhaps unsurprisingly, this performs an <code>ls</code> in the <em>current</em> directory which in this case is where <a href="https://github.com/data-intuitive/viash">viash</a> is running. This example, while illustrative, does not capture what <a href="https://github.com/data-intuitive/viash">viash</a> is and can be used for. It’s just a wrapper around the <code>ls</code> command.</p>
<p>Let’s go one step further.</p>
<h2 id="example-2-adding-some-arguments">Example 2: adding some arguments</h2>
<p>Software components are (usually) not useful unless they have some arguments which you can specify and change.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode yaml"><code class="sourceCode yaml"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true"></a><span class="fu">functionality</span><span class="kw">:</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true"></a><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> intro_example2</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true"></a><span class="at"> </span><span class="fu">arguments</span><span class="kw">:</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"-l"</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> boolean_true</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"-a"</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> boolean_true</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true"></a><span class="at"> </span><span class="fu">resources</span><span class="kw">:</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> executable</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true"></a><span class="at"> </span><span class="fu">path</span><span class="kw">:</span><span class="at"> ls</span></span></code></pre></div>
<p>We added two arguments to the <code>arguments</code> list. The arguments are flags and if we specify for <code>-l</code> it means <em>long listing</em> is one which corresponds to <code>boolean_true</code>.</p>
<p>This is what happens when you run <a href="https://github.com/data-intuitive/viash">viash</a> in a few different scenarios:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> run src/intro_example2.vsh.yaml</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true"></a><span class="ex">bin</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true"></a><span class="ex">Makefile</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true"></a><span class="ex">README.html</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true"></a><span class="ex">README.md</span></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true"></a><span class="ex">README.pdf</span></span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true"></a><span class="ex">README.Rmd</span></span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true"></a><span class="ex">src</span></span></code></pre></div>
<p>There is no difference with the previous version of the component. Now, let us pass the argument <code>-l</code> to <code>intro_example2</code>:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> run src/intro_example2.vsh.yaml -- -l</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true"></a><span class="ex">total</span> 144</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true"></a><span class="ex">drwxrwxr-x.</span> 1 rcannood rcannood 84 Feb 5 12:38 bin</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true"></a><span class="ex">-rw-rw-r--.</span> 1 rcannood rcannood 687 Feb 5 09:15 Makefile</span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true"></a><span class="ex">-rw-rw-r--.</span> 1 rcannood rcannood 53980 Feb 5 12:33 README.html</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true"></a><span class="ex">-rw-rw-r--.</span> 1 rcannood rcannood 17383 Feb 5 12:33 README.md</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true"></a><span class="ex">-rw-rw-r--.</span> 1 rcannood rcannood 50769 Feb 5 12:33 README.pdf</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 10041 Feb 5 12:38 README.Rmd</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true"></a><span class="ex">drwxr-xr-x.</span> 1 rcannood rcannood 294 Feb 5 12:28 src</span></code></pre></div>
<p>Please note that options <em>before</em> the <code>--</code> are considered for <a href="https://github.com/data-intuitive/viash">viash</a> while options after the <code>--</code> are for the tool that is wrapped (in this case <code>ls</code>).</p>
<h2 id="example-3-setting-different-argument-types">Example 3: setting different argument types</h2>
<p>Not all arguments are boolean flags such as specified in the previous example. In this <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a>, we added an extra argument that corresponds to the path which we want to <em>list</em>.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode yaml"><code class="sourceCode yaml"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true"></a><span class="fu">functionality</span><span class="kw">:</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true"></a><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> intro_example3</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true"></a><span class="at"> </span><span class="fu">arguments</span><span class="kw">:</span></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"-l"</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> boolean_true</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"-a"</span></span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> boolean_true</span></span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"path"</span></span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> file</span></span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true"></a><span class="at"> </span><span class="fu">default</span><span class="kw">:</span><span class="at"> .</span></span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true"></a><span class="at"> </span><span class="fu">resources</span><span class="kw">:</span></span>
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> executable</span></span>
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true"></a><span class="at"> </span><span class="fu">path</span><span class="kw">:</span><span class="at"> ls</span></span></code></pre></div>
<p>Running this component will still list the contents of the current directory (like before).</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> run src/intro_example3.vsh.yaml -- -l</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true"></a><span class="ex">total</span> 144</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true"></a><span class="ex">drwxrwxr-x.</span> 1 rcannood rcannood 84 Feb 5 12:38 bin</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true"></a><span class="ex">-rw-rw-r--.</span> 1 rcannood rcannood 687 Feb 5 09:15 Makefile</span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true"></a><span class="ex">-rw-rw-r--.</span> 1 rcannood rcannood 53980 Feb 5 12:33 README.html</span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true"></a><span class="ex">-rw-rw-r--.</span> 1 rcannood rcannood 17383 Feb 5 12:33 README.md</span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true"></a><span class="ex">-rw-rw-r--.</span> 1 rcannood rcannood 50769 Feb 5 12:33 README.pdf</span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 10041 Feb 5 12:38 README.Rmd</span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true"></a><span class="ex">drwxr-xr-x.</span> 1 rcannood rcannood 294 Feb 5 12:28 src</span></code></pre></div>
<p>However, we can now also list the contents of a different directory.</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> run src/intro_example3.vsh.yaml -- src/ -l</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true"></a><span class="ex">total</span> 28</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 89 Jan 28 08:35 intro_example1.vsh.yaml</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 186 Jan 28 08:35 intro_example2.vsh.yaml</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 239 Jan 28 08:35 intro_example3.vsh.yaml</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 543 Jan 28 08:35 intro_example4.vsh.yaml</span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 551 Feb 5 12:35 intro_example5.vsh.yaml</span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 593 Jan 28 08:35 intro_example6.vsh.yaml</span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 49 Feb 5 12:27 script.sh</span></code></pre></div>
<p>You can always retrieve information about the component by requesting the included help.</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> run src/intro_example3.vsh.yaml -- -h</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true"></a></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true"></a></span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true"></a><span class="ex">Options</span>:</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true"></a> <span class="ex">-l</span></span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true"></a> <span class="ex">type</span>: boolean_true</span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true"></a></span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true"></a> <span class="ex">-a</span></span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true"></a> <span class="ex">type</span>: boolean_true</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true"></a></span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true"></a> <span class="fu">file</span></span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true"></a> <span class="ex">type</span>: file, default: .</span></code></pre></div>
<p>Note that there are many more argument types than a flag or a file. These are not very useful for now, but come in handy when wrapping R/Python/JavaScript scripts. For more information, see the documentation regarding the <a href="https://www.data-intuitive.com/viash_docs/config/functionality">functionality</a> specifications.</p>
<h2 id="example-4-adding-documentation">Example 4: adding documentation</h2>
<p>The help from the last <code>intro_example3</code> does not show a lot of useful information. Let’s add some documentation regarding the component and its parameters.</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode yaml"><code class="sourceCode yaml"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true"></a><span class="fu">functionality</span><span class="kw">:</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true"></a><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> intro_example4</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true"></a><span class="at"> </span><span class="fu">version</span><span class="kw">:</span><span class="at"> </span><span class="fl">0.4</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true"></a><span class="fu"> description</span><span class="kw">: </span><span class="ch">|</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true"></a> List information about the files (the current directory by default) </span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true"></a> in alphabetical order.</span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true"></a><span class="at"> </span><span class="fu">arguments</span><span class="kw">:</span></span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"-l"</span></span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> boolean_true</span></span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true"></a><span class="at"> </span><span class="fu">description</span><span class="kw">:</span><span class="at"> </span><span class="st">"Use a long listing format."</span></span>
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"-a"</span></span>
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> boolean_true</span></span>
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true"></a><span class="at"> </span><span class="fu">description</span><span class="kw">:</span><span class="at"> </span><span class="st">"Do not ignore entries starting with '.'."</span></span>
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"path"</span></span>
<span id="cb12-15"><a href="#cb12-15" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> file</span></span>
<span id="cb12-16"><a href="#cb12-16" aria-hidden="true"></a><span class="at"> </span><span class="fu">description</span><span class="kw">:</span><span class="at"> </span><span class="st">"Which directory to list the contents of."</span></span>
<span id="cb12-17"><a href="#cb12-17" aria-hidden="true"></a><span class="at"> </span><span class="fu">default</span><span class="kw">:</span><span class="at"> .</span></span>
<span id="cb12-18"><a href="#cb12-18" aria-hidden="true"></a><span class="at"> </span><span class="fu">resources</span><span class="kw">:</span></span>
<span id="cb12-19"><a href="#cb12-19" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> executable</span></span>
<span id="cb12-20"><a href="#cb12-20" aria-hidden="true"></a><span class="at"> </span><span class="fu">path</span><span class="kw">:</span><span class="at"> ls</span></span></code></pre></div>
<p>In doing so, the help message becomes a lot more useful in reminding yourself and other users how to use the components.</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> run src/intro_example4.vsh.yaml -- -h</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true"></a><span class="ex">List</span> information about the files (the current directory by default) </span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true"></a><span class="kw">in</span> <span class="ex">alphabetical</span> order.</span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true"></a></span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true"></a><span class="ex">Options</span>:</span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true"></a> <span class="ex">-l</span></span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true"></a> <span class="ex">type</span>: boolean_true</span>
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true"></a> <span class="ex">Use</span> a long listing format.</span>
<span id="cb13-9"><a href="#cb13-9" aria-hidden="true"></a></span>
<span id="cb13-10"><a href="#cb13-10" aria-hidden="true"></a> <span class="ex">-a</span></span>
<span id="cb13-11"><a href="#cb13-11" aria-hidden="true"></a> <span class="ex">type</span>: boolean_true</span>
<span id="cb13-12"><a href="#cb13-12" aria-hidden="true"></a> <span class="ex">Do</span> not ignore entries starting with <span class="st">'.'</span>.</span>
<span id="cb13-13"><a href="#cb13-13" aria-hidden="true"></a></span>
<span id="cb13-14"><a href="#cb13-14" aria-hidden="true"></a> <span class="fu">file</span></span>
<span id="cb13-15"><a href="#cb13-15" aria-hidden="true"></a> <span class="ex">type</span>: file, default: .</span>
<span id="cb13-16"><a href="#cb13-16" aria-hidden="true"></a> <span class="ex">Which</span> directory to list the contents of.</span></code></pre></div>
<h2 id="example-4-part-2-building-an-executable">Example 4 part 2: building an <em>executable</em></h2>
<p>Suppose <code>intro_example4</code> from above is exactly what we need as standalone tool for ourselves or other people to use. Obviously, providing everyone access to <a href="https://github.com/data-intuitive/viash">viash</a> and then letting them access the <code>intro_example4.vsh.yaml</code> file in order to run the above commands would not simplify things at all!</p>
<p>Time to introduce a second <a href="https://github.com/data-intuitive/viash">viash</a> command, namely <a href="https://www.data-intuitive.com/viash_docs/commands/run"><code>viash build</code></a>. This command takes a <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a> as input, and generates an executable as output.</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> build src/intro_example4.vsh.yaml -o bin</span></code></pre></div>
<p>After running the above command, viash will have generated a file at <code>bin/intro_example4</code>. It contains all the functionality that we saw in the above examples:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">bin/intro_example4</span> -h</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true"></a><span class="ex">List</span> information about the files (the current directory by default) </span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true"></a><span class="kw">in</span> <span class="ex">alphabetical</span> order.</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true"></a></span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true"></a><span class="ex">Options</span>:</span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true"></a> <span class="ex">-l</span></span>
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true"></a> <span class="ex">type</span>: boolean_true</span>
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true"></a> <span class="ex">Use</span> a long listing format.</span>
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true"></a></span>
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true"></a> <span class="ex">-a</span></span>
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true"></a> <span class="ex">type</span>: boolean_true</span>
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true"></a> <span class="ex">Do</span> not ignore entries starting with <span class="st">'.'</span>.</span>
<span id="cb15-13"><a href="#cb15-13" aria-hidden="true"></a></span>
<span id="cb15-14"><a href="#cb15-14" aria-hidden="true"></a> <span class="fu">file</span></span>
<span id="cb15-15"><a href="#cb15-15" aria-hidden="true"></a> <span class="ex">type</span>: file, default: .</span>
<span id="cb15-16"><a href="#cb15-16" aria-hidden="true"></a> <span class="ex">Which</span> directory to list the contents of.</span></code></pre></div>
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">bin/intro_example4</span> src/ -l</span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true"></a><span class="ex">total</span> 28</span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 89 Jan 28 08:35 intro_example1.vsh.yaml</span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 186 Jan 28 08:35 intro_example2.vsh.yaml</span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 239 Jan 28 08:35 intro_example3.vsh.yaml</span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 543 Jan 28 08:35 intro_example4.vsh.yaml</span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 551 Feb 5 12:35 intro_example5.vsh.yaml</span>
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 593 Jan 28 08:35 intro_example6.vsh.yaml</span>
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true"></a><span class="ex">-rw-r--r--.</span> 1 rcannood rcannood 49 Feb 5 12:27 script.sh</span></code></pre></div>
<p>You can now share this <code>bin/intro_example4</code> file with others, or add it to your <code>~/bin</code> directory to turn it into a system-wide command.</p>
<h2 id="example-5-wrapping-a-script">Example 5: Wrapping a script</h2>
<p>While running a command wrapped as a <a href="https://github.com/data-intuitive/viash">viash</a> component could be useful in <em>some</em> form or another, we will usually want to run something a bit more custom or elaborate. Say you want to run the <code>intro_example4</code> component from above but this time filtering out certain files/directories based on their name. We could do just that by means of a simple CLI instruction that we put in a script:</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true"></a><span class="co">#!/bin/bash</span></span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true"></a></span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true"></a><span class="fu">ls</span> <span class="st">"</span><span class="va">$par_path</span><span class="st">"</span> <span class="kw">|</span> <span class="fu">grep</span> <span class="st">"</span><span class="va">$par_filter</span><span class="st">"</span></span></code></pre></div>
<p>In combination with the following <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a>:</p>
<div class="sourceCode" id="cb18"><pre class="sourceCode yaml"><code class="sourceCode yaml"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true"></a><span class="fu">functionality</span><span class="kw">:</span></span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true"></a><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> intro_example5</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true"></a><span class="at"> </span><span class="fu">version</span><span class="kw">:</span><span class="at"> </span><span class="fl">0.5</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true"></a><span class="fu"> description</span><span class="kw">: </span><span class="ch">|</span></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true"></a> List information about the files (the current directory by default) </span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true"></a> in alphabetical order, filtered by a regular expression.</span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true"></a><span class="at"> </span><span class="fu">arguments</span><span class="kw">:</span></span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"path"</span></span>
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> file</span></span>
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true"></a><span class="at"> </span><span class="fu">description</span><span class="kw">:</span><span class="at"> </span><span class="st">"Which directory to list the contents of."</span></span>
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true"></a><span class="at"> </span><span class="fu">default</span><span class="kw">:</span><span class="at"> .</span></span>
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"--filter"</span></span>
<span id="cb18-13"><a href="#cb18-13" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> string</span></span>
<span id="cb18-14"><a href="#cb18-14" aria-hidden="true"></a><span class="at"> </span><span class="fu">description</span><span class="kw">:</span><span class="at"> </span><span class="st">"A regular expression to filter the listed files."</span></span>
<span id="cb18-15"><a href="#cb18-15" aria-hidden="true"></a><span class="at"> </span><span class="fu">default</span><span class="kw">:</span><span class="at"> </span><span class="st">'.*'</span></span>
<span id="cb18-16"><a href="#cb18-16" aria-hidden="true"></a><span class="at"> </span><span class="fu">resources</span><span class="kw">:</span></span>
<span id="cb18-17"><a href="#cb18-17" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> bash_script</span></span>
<span id="cb18-18"><a href="#cb18-18" aria-hidden="true"></a><span class="at"> </span><span class="fu">path</span><span class="kw">:</span><span class="at"> script.sh</span></span>
<span id="cb18-19"><a href="#cb18-19" aria-hidden="true"></a><span class="fu">platforms</span><span class="kw">:</span></span>
<span id="cb18-20"><a href="#cb18-20" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> native</span></span></code></pre></div>
<p>We get results like this:</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> run src/intro_example5.vsh.yaml -- src/ --filter <span class="st">"^s.*"</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true"></a><span class="ex">script.sh</span></span></code></pre></div>
<p>A lot is happening here at once, so let’s unwrap this. We did not <em>build</em> the executable in this example, but just run <a href="https://www.data-intuitive.com/viash_docs/commands/run"><code>viash run</code></a> on on the <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a>. This config contains a pointer (relative path) to the <code>script.sh</code> file that contains parameters. Those parameters are defined in the <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a> and are automatically resolved and parsed when running the wrapped <a href="https://github.com/data-intuitive/viash">viash</a> version of the script.The <code>--filter</code> argument takes a regular expression, it is simply passed to <code>grep</code> in <code>script.sh</code>.</p>
<p>If you would want to achieve something similar with just Docker without <a href="https://github.com/data-intuitive/viash">viash</a>, you are in for some serious Bash development. But it does not stop here, because in addition to support for wrapping Bash scripts, <a href="https://github.com/data-intuitive/viash">viash</a> also supports wrapping Python, R, JavaScript, and Scala scripts.</p>
<h2 id="example-6-running-the-component-inside-a-docker-container">Example 6: running the component inside a Docker container</h2>
<p>In the above examples, we ran the components on our local system. This is simple as long as the wrapped tool at hand (<code>ls</code> in this case) is always available on the local system. However, this assumption generally does not hold true. <a href="https://github.com/data-intuitive/viash">viash</a> not only supports running components on the native system, but can also run components inside a Docker container.</p>
<p>To make use of this functionality, we need to get into the the ‘platforms’ section of the <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a>, which can contain one or more execution platforms. In this case, we defined platforms: a <em>native</em> one (local machine) and a <em>docker</em> one.</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode yaml"><code class="sourceCode yaml"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true"></a><span class="fu">functionality</span><span class="kw">:</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true"></a><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> intro_example6</span></span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true"></a><span class="at"> </span><span class="fu">version</span><span class="kw">:</span><span class="at"> </span><span class="fl">0.6</span></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true"></a><span class="fu"> description</span><span class="kw">: </span><span class="ch">|</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true"></a> List information about the files (the current directory by default) </span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true"></a> in alphabetical order, filtered by a regular expression.</span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true"></a><span class="at"> </span><span class="fu">arguments</span><span class="kw">:</span></span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"path"</span></span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> file</span></span>
<span id="cb20-10"><a href="#cb20-10" aria-hidden="true"></a><span class="at"> </span><span class="fu">description</span><span class="kw">:</span><span class="at"> </span><span class="st">"Which directory to list the contents of."</span></span>
<span id="cb20-11"><a href="#cb20-11" aria-hidden="true"></a><span class="at"> </span><span class="fu">default</span><span class="kw">:</span><span class="at"> .</span></span>
<span id="cb20-12"><a href="#cb20-12" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">name</span><span class="kw">:</span><span class="at"> </span><span class="st">"--filter"</span></span>
<span id="cb20-13"><a href="#cb20-13" aria-hidden="true"></a><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> string</span></span>
<span id="cb20-14"><a href="#cb20-14" aria-hidden="true"></a><span class="at"> </span><span class="fu">description</span><span class="kw">:</span><span class="at"> </span><span class="st">"A regular expression to filter the listed files."</span></span>
<span id="cb20-15"><a href="#cb20-15" aria-hidden="true"></a><span class="at"> </span><span class="fu">default</span><span class="kw">:</span><span class="at"> </span><span class="st">'.*'</span></span>
<span id="cb20-16"><a href="#cb20-16" aria-hidden="true"></a><span class="at"> </span><span class="fu">resources</span><span class="kw">:</span></span>
<span id="cb20-17"><a href="#cb20-17" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> bash_script</span></span>
<span id="cb20-18"><a href="#cb20-18" aria-hidden="true"></a><span class="at"> </span><span class="fu">path</span><span class="kw">:</span><span class="at"> script.sh</span></span>
<span id="cb20-19"><a href="#cb20-19" aria-hidden="true"></a><span class="fu">platforms</span><span class="kw">:</span></span>
<span id="cb20-20"><a href="#cb20-20" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> native</span></span>
<span id="cb20-21"><a href="#cb20-21" aria-hidden="true"></a><span class="at"> </span><span class="kw">-</span><span class="at"> </span><span class="fu">type</span><span class="kw">:</span><span class="at"> docker</span></span>
<span id="cb20-22"><a href="#cb20-22" aria-hidden="true"></a><span class="at"> </span><span class="fu">image</span><span class="kw">:</span><span class="at"> ubuntu:latest</span></span></code></pre></div>
<p>By default, <a href="https://github.com/data-intuitive/viash">viash</a> will use the first platform specified in the <a href="https://www.data-intuitive.com/viash_docs/config">viash config</a>, which in this case the native platform. In order to build an executable which uses Docker in the backend, we need to pass this information as follows:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">viash</span> build src/intro_example6.vsh.yaml -o bin -p docker</span></code></pre></div>
<p>The executable <code>bin/intro_example6</code> now automatically runs inside Docker.</p>
<div class="sourceCode" id="cb22"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">bin/intro_example6</span> src/ --filter <span class="st">'^s.*'</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true"></a><span class="ex">script.sh</span></span></code></pre></div>
<p>If the <code>ubuntu</code> image is not yet available on your system, this command will automatically fetch it before running the tool. You can verify for yourself that the result of this listing is not the same as what you would have if you ran on your local system.</p>
<p>Please note that if you wanted to do this exact thing by using Docker itself, you would have to use a CLI instruction which looks something like this:</p>
<div class="sourceCode" id="cb23"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true"></a><span class="op">></span> <span class="ex">docker</span> run --rm -v <span class="kw">`</span><span class="bu">pwd</span><span class="kw">`</span>:/mount ubuntu:latest ls /mount/src <span class="kw">|</span> <span class="fu">grep</span> <span class="st">'^s.*'</span></span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true"></a><span class="ex">script.sh</span></span></code></pre></div>
<p>While this is all still manageable, it could quickly become more complicated, but that is for a later section. In what follows, we will also come back not only to running inside a container but also generating a container (based on a base image), tagging and versioning.</p>
</body>
</html>