Skip to content

Commit 29e9874

Browse files
Add clarifications about git in README (#81)
Co-authored-by: Παναγιώτης Γεωργακόπουλος <[email protected]>
1 parent f0f7533 commit 29e9874

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

README.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> _**not just sliders!**_
44
5-
Web server to run just the @bind parts of a [Pluto.jl](https://github.com/fonsp/Pluto.jl) notebook.
5+
Web server to run just the @bind parts of a [Pluto.jl](https://github.com/fonsp/Pluto.jl) notebook.
66

77
See it in action at [computationalthinking.mit.edu](https://computationalthinking.mit.edu/)! Sliders, buttons and camera inputs work _instantly_, without having to wait for a Julia process. Plutoplutopluto
88

@@ -36,7 +36,7 @@ PlutoSliderServer.export_notebook("path/to/notebook.jl")
3636
```
3737

3838
## 2. Run a slider server
39-
The main functionality of PlutoSliderServer is to run a ***slider server***. This is a web server that **runs a notebook using Pluto**, and allows visitors to **change the values of `@bind`-ed variables**.
39+
The main functionality of PlutoSliderServer is to run a ***slider server***. This is a web server that **runs a notebook using Pluto**, and allows visitors to **change the values of `@bind`-ed variables**.
4040

4141
The important **differences** between running a *slider server* and running Pluto with public access are:
4242
- A *slider server* can only set `@bind` values, it is not possible to change the notebook's code.
@@ -52,7 +52,7 @@ PlutoSliderServer.run_notebook("path/to/notebook.jl")
5252
```
5353

5454
## 3. _(WIP): Precomputed slider server_
55-
Many input elements only have a finite number of possible values, for example, `PlutoUI.Slider(5:15)` can only have 11 values. For finite inputs like the slider, PlutoSliderServer can run the slider server **in advance**, and precompute the results to all possible inputs (in other words: precompute the response to all possible requests).
55+
Many input elements only have a finite number of possible values, for example, `PlutoUI.Slider(5:15)` can only have 11 values. For finite inputs like the slider, PlutoSliderServer can run the slider server **in advance**, and precompute the results to all possible inputs (in other words: precompute the response to all possible requests).
5656

5757
This will generate a directory of subdirectories and files, each corresponding to a possible request. You can host this directory along with the generated HTML file (e.g. on GitHub pages), and Pluto will be able to use these pregenerated files as if they are a slider server! **You can get the interactivity of a slider server, without running a Julia server!**
5858

@@ -71,7 +71,7 @@ See `PlutoSliderServer.export_directory` and `PlutoSliderServer.run_directory`.
7171

7272
After scanning a directory for notebook files, you can ask Pluto to continue watching the directory for changes. When notebook files are added/removed, they are also added/removed from the server. When a notebook file changes, the notebook session is restarted.
7373

74-
This works especially well when this directory is a git-tracked directory. When running in a git directory, PlutoSliderServer can keep `git pull`ing the directory, updating from the repository automatically.
74+
This works especially well when this directory is a git-tracked directory. When running in a git directory, PlutoSliderServer can keep `git pull`ing the directory, updating from the repository automatically.
7575

7676
See the `SliderServer_watch_dir` option and `PlutoSliderServer.run_git_directory`.
7777

@@ -157,9 +157,9 @@ There are two ways to change configurations: using keywords arguments, and using
157157
Our functions can take keyword arguments, for example:
158158

159159
```julia
160-
run_directory("my_notebooks";
161-
SliderServer_port=8080,
162-
SliderServer_host="0.0.0.0",
160+
run_directory("my_notebooks";
161+
SliderServer_port=8080,
162+
SliderServer_host="0.0.0.0",
163163
Export_baked_notebookfile=false,
164164
)
165165
```
@@ -215,13 +215,22 @@ touch pluto-slider-server-environment/PlutoDeployment.toml
215215
# edit the file...
216216
```
217217

218-
### 3. Run it
218+
### 3. Run it
219219
Let's try running it locally before setting up our server:
220220
```shell
221221
julia --project="pluto-slider-server-environment" -e "import PlutoSliderServer; PlutoSliderServer.run_git_directory(\".\")"
222222
```
223223

224-
`run_git_directory` will periodically call `git pull`, which requires the `start_dir` to be a repository in which you can `git pull` without password (which means it's either public, or you have the required keys in `~/.ssh/` and your git's provider security page!)
224+
`run_git_directory` will periodically call `git pull`, which requires the `start_dir` to be a repository in which you can `git pull` without password (which means it's either public, or you have the required keys in `~/.ssh/` and your git's provider security page!)
225+
226+
>**Note**
227+
>Julia by default uses `libgit2` for git operations, [which can be problematic](https://github.com/JuliaLang/Pkg.jl/issues/2679). It is also known to cause issues in cloud environments like AWS's CodeCommit
228+
>where re-authentication is required at regular intervals.
229+
>
230+
> A simple workaround is to set the `JULIA_PKG_USE_CLI_GIT` environment variable to `true`, which will fallback to the system git (the one on the shell).
231+
> Make sure that this is installed! (`sudo apt-get install git` does the trick in Ubuntu).
232+
233+
Also note that `git pull` may fail on the server if you force push the branch from your laptop, so handle history-rewriting commands, like `git push -f`, `git rebase` etc with care!
225234

226235
### 4. Set up a server to run PlutoSliderServer
227236
For this step, we'll assume a very specific but also common setup:
@@ -238,12 +247,12 @@ sudo apt-get upgrade
238247

239248
You should run `systemd --version` to verify that we have version 230 or higher.
240249

241-
#### 1. Install Julia (run as root)
250+
#### 1. Install Julia (run as root)
242251
```shell
243-
# You can edit me: The Julia version (1.7.3) split into three parts:
252+
# You can edit me: The Julia version (1.8.0) split into three parts:
244253
JULIA_MAJOR_VERSION=1
245-
JULIA_MINOR_VERSION=7
246-
JULIA_PATCH_VERSION=3
254+
JULIA_MINOR_VERSION=8
255+
JULIA_PATCH_VERSION=0
247256

248257
JULIA_VERSION="$(echo $JULIA_MAJOR_VERSION).$(echo $JULIA_MINOR_VERSION).$(echo $JULIA_PATCH_VERSION)"
249258

@@ -287,6 +296,10 @@ sudo mv $TEMPFILE /etc/systemd/system/pluto-server.service
287296
TEMPFILE=$(mktemp)
288297
cat > $TEMPFILE << __EOF__
289298
#!/bin/bash
299+
300+
# this env var allows us to side step various issues with the Julia-bundled git
301+
export JULIA_PKG_USE_CLI_GIT=true
302+
290303
cd /home/<your-username>/<your-repo> # Make sure to change to the absolute path to your repository. Don't use ~.
291304
julia --project="pluto-slider-server-environment" -e "import Pkg; Pkg.instantiate(); import PlutoSliderServer; PlutoSliderServer.run_git_directory(\".\")"
292305
__EOF__
@@ -334,25 +347,24 @@ The most similar project is [PlutoStaticHTML.jl](https://github.com/rikhuijzer/P
334347
This means that the output of PlutoSliderServer.jl will look exactly the same as what you see while writing the notebook. Output from PlutoStaticHTML.jl is more minimal, which means that it loads faster, it can be styled with CSS, and it can more easily be embedded within other web pages (like Documenter.jl sections).
335348

336349
Other Julia packages which export to HTML/PDF, but not necessarily with Pluto notebook files as input, include:
337-
- Documenter.jl
350+
- Documenter.jl
338351
- Franklin.jl
339352
- Books.jl
340353
- Weave.jl
341354

342355
## Slider server
343-
PlutoSliderServer is the only package that lets you run a *slider server* for Pluto notebooks (an interactive site to interact with a Pluto notebook through `@bind`).
356+
PlutoSliderServer is the only package that lets you run a *slider server* for Pluto notebooks (an interactive site to interact with a Pluto notebook through `@bind`).
344357

345358
There are alternatives for running a Julia-backed interactive site if your code is *not* a Pluto notebook, including [JSServe.jl](https://github.com/SimonDanisch/JSServe.jl), [Stipple.jl](https://github.com/GenieFramework/Stipple.jl) and [Dash.jl](https://github.com/plotly/Dash.jl), each with their own philosophy and ideal use case. *(Feel free to suggest others!)*
346359

347360
## Precomputer slider server
348361
[PlutoStaticHTML.jl](https://github.com/rikhuijzer/PlutoStaticHTML.jl) should also have this feature in the future, after it is added to PlutoSliderServer (it is still [being worked on](https://github.com/JuliaPluto/PlutoSliderServer.jl/pull/29)).
349362

350-
If you code is *not* a Pluto notebook, then [JSServe.jl](https://github.com/SimonDanisch/JSServe.jl) also has precomputing abilities, with a different approach and philosophy.
363+
If you code is *not* a Pluto notebook, then [JSServe.jl](https://github.com/SimonDanisch/JSServe.jl) also has precomputing abilities, with a different approach and philosophy.
351364

352365
# Authentication and security
353-
Since this server is a new and experimental concept, we highly recommend that you run it inside an isolated environment. While visitors are not able to change the notebook code, it is possible to manipulate the API to set bound values to arbitrary objects. For example, when your notebook uses `@bind x Slider(1:10)`, the API could be used to set the `x` to `9000`, `[10,20,30]` or `"👻"`.
366+
Since this server is a new and experimental concept, we highly recommend that you run it inside an isolated environment. While visitors are not able to change the notebook code, it is possible to manipulate the API to set bound values to arbitrary objects. For example, when your notebook uses `@bind x Slider(1:10)`, the API could be used to set the `x` to `9000`, `[10,20,30]` or `"👻"`.
354367

355368
In the future, we are planning to implement a hook that allows widgets (such as `Slider`) to validate a value before it is run: [`AbstractPlutoDingetjes.Bonds.validate_value`](https://docs.juliahub.com/AbstractPlutoDingetjes/UHbnu/1.1.1/#AbstractPlutoDingetjes.Bonds.validate_value-Tuple{Any,%20Any}).
356369

357370
Of course, we are not security experts, and this software does not come with any kind of security guarantee. To be completely safe, assume that someone who can visit the server can execute arbitrary code in the notebook, despite our measures to prevent it. Run PlutoSliderServer in a containerized environment.
358-

0 commit comments

Comments
 (0)