Skip to content

Commit 18f3b39

Browse files
authored
Merge pull request #1717 from opensafely/opensafely-launch
Add docs for opensafely launch
2 parents d4a0fb0 + 9ab458c commit 18f3b39

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

docs/opensafely-cli.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,39 +194,56 @@ opensafely exec IMAGE bash
194194

195195
This can be useful if you want to explore the image manually.
196196

197+
### `launch` - Run web based interactive tools
197198

198-
### `rstudio` - Running RStudio Server
199+
Many users may prefer to use some of the interactive development environments that are commonly used for different languages, like RStudio or JupyterLab.
199200

200-
An alternative method to open your project in an RStudio Server session is to open your research repository in [Codespaces](/getting-started/how-to/use-github-codespaces-in-your-project/#how-to-access-rstudio).
201+
Using `opensafely launch`, you can run these tools from the OpenSAFELY images, accessing them via your browser. This means that code you write and run in these tools will be running the OpenSAFELY-provided environment, with the right dependencies and versions, rather than whatever you have installed on your own machine.
201202

202-
This subcommand provides the RStudio interface to the r image. This lets you run your code in RStudio using the same versions of R and all the packages that are the OpenSAFELY secure backend.
203+
The supported tools of RStudio and JupyterLab are documented below, but they share a common set of options, which you can see with
204+
205+
```
206+
opensafely launch --help
207+
```
208+
209+
210+
#### `opensafely launch rstudio` - Running RStudio Server
211+
212+
This sub-command provides the RStudio interface to the R image. This lets you run your code in RStudio using the same versions of R and all the packages that are available in the OpenSAFELY secure backend.
213+
Note that if you are using a Github [Codespace](/getting-started/how-to/use-github-codespaces-in-your-project/#how-to-access-rstudio), then this is run automatically for you.
203214

204215
To launch an RStudio Server session please navigate to your research repository and run
205216

206217
```bash
207-
opensafely rstudio
218+
opensafely launch rstudio
208219
```
209220

210-
This will launch an RStudio Server session in a browser window. A message in your terminal will tell you which port to browse to.
221+
This will launch an RStudio Server session, and open it in a browser window. A message in your terminal will tell you which port it is running on, in case you need to know.
222+
223+
By default it will use the most recent version of the OpenSAFELY R image, but you can specify an older version with:
224+
225+
```bash
226+
opensafely launch rstudio:v1
227+
```
211228

212229
In your RStudio Server session you can work on your files as usual, including saving your edits.
213230

214231
If you have an `.Rproj` file at the top level of your repository, the command will detect this and will open the RStudio Server session in RStudio's project mode. In this mode the Git pane is available, so you can make commits, or you can make commits locally as you usually do.
215232

216233
To end your RStudio Server session press ++ctrl+c++ in the Terminal window in which you ran the `opensafely rstudio` command.
217234

218-
Note that the `opensafely` CLI is not vendored within the rstudio image. Hence to use CLI commands such as `opensafely run`, please do so from a local Terminal session and not from the Terminal pane in your RStudio Server session. Whereas, the `opensafely` CLI is vendored within the Codespaces version of RStudio Server, and so you can use the RStudio Terminal in this case.
235+
Note that the `opensafely` CLI is not available within the RStudio image. Hence to use CLI commands such as `opensafely run`, please do so from a local Terminal session and not from the Terminal pane in your RStudio Server session. If you are using a Codespace, the `opensafely` CLI **is** availablle within the RStudio Server session, and so you can use the RStudio Terminal in this case.
219236

220237
Users with Apple Silicon computers need to [enable Rosetta emulation](/install-docker/#macs-with-an-apple-silicon-processor). Since Docker Desktop 4.25.0 this feature has been enabled by default. For Docker Desktop versions between 4.16.0 and 4.24.4 this setting can be found in Settings under the _Features in development_ and then _Beta features_ tab. The `opensafely rstudio` command will not run under either the Docker Virtual Machine Manager virtualization (since Docker Desktop 4.35.0) nor the legacy QEMU virtualization.
221238

222-
Users with Windows computers will notice that after opening a repository in RStudio project mode that their _.Rproj_ file will have had its line endings changed (from CRLF to LF). This is because RStudio always rewrites _.Rproj_ files on opening a project. You can simply discard these changes, for example, in GitHub Desktop by right clicking and selecting _Discard Changes_. Alternatively, this can be overcome by resaving your _.Rproj_ file with LF line endings, then adding a special case, as shown below, to your _.gitattributes_ file to tell Git to always save this file with LF line endings (this setting needs to placed on a line after the `* text=auto` line). Make sure to commit this addition to your _.gitattributes_ file into your repository.
239+
Users with Windows computers will notice that after opening a repository in RStudio project mode that their _.Rproj_ file will have had its line endings changed (from CRLF to LF). This is because RStudio always rewrites _.Rproj_ files on opening a project. You can simply discard these changes, for example, in GitHub Desktop by right clicking and selecting _Discard Changes_. Alternatively, this can be overcome by re-saving your _.Rproj_ file with LF line endings, then adding a special case, as shown below, to your _.gitattributes_ file to tell Git to always save this file with LF line endings (this setting needs to placed on a line after the `* text=auto` line). Make sure to commit this addition to your _.gitattributes_ file into your repository.
223240

224241
```text
225242
*.Rproj text eol=lf
226243
```
227244

228245

229-
### `jupyter` - Running JupyterLab
246+
#### `opensafely launch jupyter` - Running JupyterLab
230247

231248
[Jupyter notebooks](https://jupyter.org/) are useful interactive
232249
environments for developing code.
@@ -246,6 +263,12 @@ copy the long URL shown by the JupyterLab logs — starting
246263
`http://localhost`… — and use that URL in a web
247264
browser to access JupyterLab.
248265

266+
By default, it will run JupyterLab in the most recent version of the python image, but you can to run an older version with:
267+
268+
```bash
269+
opensafely launch jupyter:v1
270+
```
271+
249272
To exit, press ++control+c++ in the command line - this also shuts down the container.
250273
Or alternatively go to File -> shutdown in the JupyterLab tab.
251274

@@ -336,7 +359,7 @@ opensafely run job_name -m 8G
336359
Over time, some left over Docker containers and volumes can build up, and take
337360
up space.
338361

339-
You can use the `clean` command in order to safely purge any such left over artifacts:
362+
You can use the `clean` command in order to safely purge any such left over artefacts:
340363

341364
`opensafely clean`
342365

0 commit comments

Comments
 (0)