-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.qmd
397 lines (287 loc) · 7.27 KB
/
index.qmd
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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
---
format:
revealjs:
transition: fade
theme: night
mermaid-format: svg
navigation-mode: linear
controls: false
from: markdown+emoji
---
# {background-image="images/julia-joppien-XFUqd0u5U7w-unsplash.jpg"}
::: notes
I'm David Aja, a member of the SE team at RStudio.
I help data scientists get their ideas into production.
I see a lot of broken things.
So that's why today I'll be talking about:
:::
# {background-image="images/julia-joppien-XFUqd0u5U7w-unsplash.jpg"}
::: columns
::: {.column width="30%"}
::: {.r-fit-text color="white"}
You <br/> should <br/> use <br/> renv.
:::
:::
::: {.column width="70%"}
:::
:::
::: fragment
(probably.)
:::
# agenda
::: columns
::: {.column width="50%"}
::: {.r-fit-text .fragment}
why
:::
:::
::: {.column width="50%"}
::: {.r-fit-text .fragment}
how
:::
:::
:::
# why
## we have a standards problem
::: fragment
what makes a project an *R* project?
:::
## what is a project?
::: {.fragment .fade-in}
> *an individual or collaborative enterprise that is carefully planned to achieve a particular aim.*
>
> -- Oxford Languages
:::
::: notes
- functional definition: a thing is what it does
:::
## what is a project?
::: r-stack
::: {.fragment .fade-in .r-fit-text }
a project *ships*.
:::
::: {.fragment }
![](images/AOL_promotional_CDs_in_Canada.jpeg)
:::
:::
## I thought this guy works at RStudio
## ceci n'est pas un projet
::: r-fit-text
\*.Rproj
:::
## `*.Rproj`
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
::: fragment
You don't ship your editor.
:::
::: {.fragment .smaller style="text-align: right;"}
:see_no_evil: I have shipped my editor.
:::
<br/>
<br/>
::: notes
- `.Rproj` is mostly editor config
- signifier but doesn't accomplish proejct goals
- Some RStudio handling of configurable R behaviors, but R doesn't know that
- I didn't get here from a history of flawless decision making.
:::
## `*.Rproj`
**necessary** (_if_ you use RStudio)
but not sufficient
# what *is* a project?
::: notes
- we're increasing the diversity of things R can do and where it does them
- behooves us to learn from other language and framework paradigms and how they think about reliably delivering product
- 12 factor is focused on deploying web applications but many lessons translate
:::
## [12factor.net](https://12factor.net)
> A twelve-factor app **never** relies on implicit existence of system-wide packages.
::: columns
::: {.column .fragment width="49%"}
It declares all dependencies, completely and exactly, via a dependency declaration manifest.
:::
::: {.column .fragment width="49%" style="text-align: right;"}
It uses a dependency isolation tool \[...\] to ensure that no implicit dependencies "leak in"
:::
:::
## leak-in
![](images/leak-in.svg)
## leak-in
![](images/leak-in-think.svg)
##
### `install_github("tidyverse/dtplyr")` {.smaller}
![](images/leak-in-install-dtplyr.svg)
##
### `install_github("tidyverse/dtplyr")` {.smaller}
![](images/oh-shit.svg)
## panic, a haiku
when do you think you <br/> want to discover that you've <br/> broken your dashboard?
::: notes
design to not be able to lock your keys in the car
:::
# how
##
::: r-fit-text
isolate.
:::
##
::: {.r .r-fit-text}
`install.packages("renv")`
:::
## `renv::init()`
or,
![](images/paste-547A1832.png)
## `.libPaths()`
::: r-stack
::: {.fragment .fade-out}
```{.r code-line-numbers="false"}
> .libPaths()
[1] "~/Library/R/x86_64/4.2/library" # user
[2] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library" # system
```
:::
::: {.fragment}
```{.r code-line-numbers="false"}
* Project '~/Documents/projects/sample-project' loaded. [renv 0.16.0]
> .libPaths()
[1] "~/Documents/projects/sample-project/renv/library/R-4.2/x86_64-apple-darwin17.0"
[2] "~/Documents/projects/sample-project/renv/sandbox/R-4.2/x86_64-apple-darwin17.0/fb4b0a46"
```
:::
:::
##
::: {.r-fit-text}
<h2>`renv::install("tidyverse/dtplyr@main")`</h2>
:::
![](images/isolate-proj-lib.svg)
## `renv::init()`; `renv::install()`
![](images/isolate-experiments.svg)
## cache, money
![](images/isolate-cache.svg)
##
::: r-fit-text
enumerate.
:::
## `renv::snapshot()`
```{.json code-line-numbers="false"}
{
...
"Packages": {
"DBI": {
"Package": "DBI",
"Version": "1.1.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "030aaec5bc6553f35347cbb1e70b1a17"
},
...
}
}
```
## `renv::snapshot()`
```{.json code-line-numbers="false"}
"R": {
"Version": "4.1.1",
"Repositories": [
{
"Name": "RSPM",
"URL": "https://packagemanager.rstudio.com/cran/latest"
}
]
},
```
## `renv::snapshot()`
```{.json code-line-numbers="false"}
"gitcellar": {
"Package": "gitcellar",
"Version": "0.0.0.9000",
"Source": "Repository",
"Repository": "https://ropensci.r-universe.dev",
"RemoteUrl": "https://github.com/ropensci-org/gitcellar",
"RemoteRef": "main",
"RemoteSha": "5c761b993720ef51aeea81a94f01e34ae0c71c84",
"Hash": "95fe2a4c4002b5d8fd674d460c6af4c1",
"Requirements": [
"R6",
"gh",
"purrr",
"tibble",
"withr"
]
},
```
##
::: r-fit-text
`renv.lock`
:::
is the project artifact we're looking for.
##
::: r-fit-text
collaborate.
:::
## `renv::status()`
```{.r}
The following package(s) are recorded in the lockfile but not installed:
_
R6 [2.5.0]
Rcpp [1.0.6]
askpass [1.1]
base64enc [0.1-3]
bslib [0.2.4]
...
sourcetools [0.1.7]
sys [3.4]
withr [2.4.0]
xtable [1.8-4]
yaml [2.2.1]
Use `renv::restore()` to install these packages.
```
## `renv::status()`
```{.r}
The following package(s) are used in the project, but are not installed:
vitessceR
Consider installing these packages, and then using `renv::snapshot()`
to record these packages in the lockfile.
```
## `renv::status()`
```{.r}
The following package(s) are no longer used in this project:
_
gh [1.3.0]
gitcellar [0.0.0.9000]
gitcreds [0.1.1]
ini [0.3.1]
Use `renv::snapshot()` to remove them from the lockfile.
```
## the workflow
::: {.smaller}
::: {.fragment .fade-out}
`renv::init()`
:::
`renv::install()`
`renv::snapshot()`
_ship_
`renv::restore()`
:::
# probably?
## I don't intend to re-use this code
::: {.r-stack .fragment}
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">The quick and dirty approach you took then comes right back at you as a boomerang. <br><br>Therefore, ban the concept of one-off altogether. No matter what the asker says, it will have to be done again, always!<br><br>3/9</p>— Edwin Thoen (@edwin_thoen) <a href="https://twitter.com/edwin_thoen/status/1526261181631152129?ref_src=twsrc%5Etfw">May 16, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
:::
## I'm purely a package developer
[article: isolation for package dev](https://rstudio.github.io/renv/articles/packages.html#isolation)
## we have an opportunity
Let's coalesce on a project standard.
::: r-fit-text
Use renv.
:::
# special thanks
Kevin Ushey