Skip to content

Commit d0fc8d9

Browse files
authored
Merge pull request #82 from revbayes/phylodocker_fix_250722
Phylodocker fix 250722
2 parents 59f5a1b + edb343c commit d0fc8d9

File tree

4 files changed

+77
-23
lines changed

4 files changed

+77
-23
lines changed

tutorials/biogeo/biogeo_simple.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,11 @@ that fixes all cladogenetic events to be equiprobable.
289289
Finally, all our DEC model components are encapsulated in the
290290
`dnPhyloCTMCClado` distribution, which is similar to
291291
`dnPhyloCTMC` except specialized to integrate over
292-
cladogenetic events. Although this dataset has four areas, it is
293-
recognized single character with states valued from 1 to $2^4$, hence
294-
`nSites=1`.
292+
cladogenetic events. This analysis uses presence/absence information
293+
for four areas to represent the species range. The model encodes
294+
each range into a single character with states valued from 1 to $2^4$.
295+
As such, we tell the phylogenetic model there is only one character
296+
(`nSites=1`).
295297

296298
m_bg ~ dnPhyloCTMCClado(tree=tree,
297299
Q=Q_DEC,

tutorials/docker/index.md

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,34 @@ redirect: false
1313

1414
Docker is a way to share pre-built, pre-configured, and platform-independent sets of programs and files. The PhyloDocker image described below comes pre-configured with RevBayes, the TensorPhylo library, and other useful software.
1515

16-
As a user, you download and a build a Docker image. Once built, you can create a Docker container from that image. Each Docker image lives on your computer and uses its resources for work. In this way, you can think of Docker as a program that runs a miniature "virtual" computer through your actual computer. A container built from PhyloDocker can be used to run RevBayes, just like you would through the terminal, but without needing to install and configure RevBayes yourself. For example:
16+
As a user, you download and a build a Docker image. Once built, you can create a Docker container from that image. Each Docker image lives on your computer and uses its resources for work. In this way, you can think of Docker as a program that runs a miniature "virtual" computer through your actual computer. A container built from PhyloDocker can be used to run RevBayes, just like you would through the terminal, but without needing to install and configure RevBayes yourself.
17+
18+
On the development side, a **Dockerfile** (a list of commands for building and configuring programs/files) is used to build an **image**, which can then be shared with others. On the user side, the image can be downloaded and run to create a **container**. Inside the container, you have access to all of the programs contained in the image, as well as any files you **mount** to the container when you run the image. It works a bit like a virtual machine, except it runs on top of the host operating system. A Docker image containing RevBayes, TensorPhylo, Python, R, Julia, and several other programs can be found on [Docker Hub](https://hub.docker.com/r/sswiston/phylo_docker).
19+
20+
This tutorial explains how to install Docker on your computer, how to obtain a RevBayes Docker image, and how to use the image to run scripts on your computer or a computing cluster. This will require a basic familiarity with command line (navigating directories and entering basic commands), but does not require much programming.
21+
22+
{% subsection Basic example %}
23+
24+
This tutorial includes a test script called `test.Rev` so that you can assess whether the RevBayes Docker container is functioning properly after being installed. The test script can be found in the `Data files and scripts` box in the left sidebar of the tutorial page. Somewhere on your computer, you should create a directory (folder) for this tutorial, download the test script, and put the test script inside the directory. You can put this directory anywhere you want on your computer, but you will need to know the filepath to the directory in order to access it from the Docker container. Here, we assume the working directory will be `/Users/mlandis/projects/docker_test`.
25+
26+
Create and run a new Docker container, and start with an interactive shell session:
1727

1828
```
1929
~ $ ### from terminal on my Mac laptop (host)
20-
~ $ docker run --name phylodocker_demo --volume /Users/mlandis/projects/docker_test:/docker_test -it sswiston/phylo_docker:slim_amd64
30+
~ $ # create and run new Docker container
31+
~ $ docker run --name phylodocker_demo \
32+
--volume /Users/mlandis/projects/docker_test:/docker_test \
33+
-it sswiston/phylo_docker:slim_amd64 \
34+
/bin/sh
35+
```
36+
37+
You should now be at the shell prompt within the Docker container! Try running the test script that is bundled with PhyloDocker.
2138

39+
```
2240
~ # ### from terminal inside Docker container
2341
~ # cd docker_test/
2442
/docker_test # ls
25-
history.txt test.Rev
43+
test.Rev
2644
/docker_test # rb test.Rev
2745
2846
RevBayes version (1.2.2)
@@ -44,25 +62,57 @@ Congrats! RevBayes is working!
4462
/docker_test # ls
4563
new_file.txt test.Rev
4664
/docker_test # exit
65+
```
66+
67+
You have closed the Docker session and returned to your computer (the host machine). Make sure the file is there. After that, find your old Docker container, resume the session, tell the world hello, then exit when done:
4768

48-
~ $ ### back on my laptop (host)
69+
```
70+
~ $ ### from terminal on laptop (host)
71+
~ $ # show new files are present
4972
~ $ ls /Users/mlandis/projects/docker_test
5073
new_file.txt test.Rev
5174
52-
~ $ ### reconnect to Docker container
75+
~ $ # show active Docker containers
76+
~ docker ps -a
77+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
78+
fb19b94184ac sswiston/phylo_docker:slim_amd64 "/bin/sh" 5 minutes ago Exited (0) 4 minutes ago phylodocker_demo
79+
80+
~ $ # resume active Docker container using start
5381
~ $ docker start -ai phylodocker_demo
54-
~ #
55-
```
5682
57-
On the development side, a **Dockerfile** (a list of commands for building and configuring programs/files) is used to build an **image**, which can then be shared with others. On the user side, the image can be downloaded and run to create a **container**. Inside the container, you have access to all of the programs contained in the image, as well as any files you **mount** to the container when you run the image. It works a bit like a virtual machine, except it runs on top of the host operating system. A Docker image containing RevBayes, TensorPhylo, Python, R, Julia, and several other programs can be found on [Docker Hub](https://hub.docker.com/r/sswiston/phylo_docker).
83+
--> Enters the Docker container <--
5884
59-
This tutorial explains how to install Docker on your computer, how to obtain a RevBayes Docker image, and how to use the image to run scripts on your computer or a computing cluster. This will require a basic familiarity with command line (navigating directories and entering basic commands), but does not require much programming.
85+
~ # ### back in the Docker container
86+
~ # echo Hello, world!
87+
Hello, world!
88+
~ # exit
89+
```
6090

61-
{% section Setting up the tutorial %}
91+
Delete your Docker container when it's done. Note, files saved to the mounted directory `/docker_test` also exist on your host computer's filesystem, so they will not be deleted:
6292

63-
{% subsection Downloading a test script %}
93+
```
94+
~ $ ### back on my laptop again (host)
95+
~ $ # remove old Docker container once done with it
96+
~ $ docker rm phylodocker_demo
97+
phylodocker_demo
98+
~ $ # files continue to exist
99+
~ $ ls /Users/mlandis/projects/docker_test
100+
new_file.txt test.Rev
101+
```
102+
{% subsection Useful Docker commands %}
103+
104+
Docker supports a large number of commands to manage images and containers (see [Docker CLI Documentation](https://docs.docker.com/reference/cli/docker/)). These six commands will cover the needs for most RevBayes users:
64105

65-
This tutorial includes a test script called `test.Rev` so that you can assess whether the RevBayes Docker container is functioning properly after being installed. The test script can be found in the `Data files and scripts` box in the left sidebar of the tutorial page. Somewhere on your computer, you should create a directory (folder) for this tutorial, download the test script, and put the test script inside the directory. You can put this directory anywhere you want on your computer, but you will need to know the filepath to the directory in order to access it from the Docker container.
106+
|---------|--------------------------------------------------------------------|
107+
| command | description |
108+
|---------|--------------------------------------------------------------------|
109+
|`docker ps -a` | lists all containers and their statuses |
110+
|`docker run --name <my_container> [ ... ]` | creates a container from the image and sets container to active; see above |
111+
|`docker start -ai <container_name>` | sets a container to active |
112+
|`docker exec -it <container_name> /bin/sh` | executes command (shell, in this case) on an active container |
113+
|`docker stop <container_name>` | sets a container to inactive |
114+
|`docker rm <container_name>` | deletes an inactive container (be sure all saved work has been transferred to the mounted directory!) |
115+
|---------|--------------------------------------------------------------------|
66116

67117
{% section Setting up Docker %}
68118

@@ -83,7 +133,7 @@ Example view of containers in Docker Desktop.
83133

84134
This is a reference to {% ref example %}
85135

86-
{% subsection Downloading the image %}
136+
{% subsection Downloading the Docker image %}
87137

88138
A Docker image containing RevBayes, TensorPhylo, Python, R, and other dependencies can be found at [hub.docker.com/r/sswiston/phylo_docker](https://hub.docker.com/r/sswiston/phylo_docker). The easiest way to obtain this image is with a `docker pull` command.
89139

@@ -133,10 +183,10 @@ You can also run the RevBayes Docker image directly from command line. This will
133183

134184
```
135185
# For Intel/AMD computers
136-
docker run --name [my_container] --volume [local_directory]:[container_directory] -it sswiston/phylo_docker:slim_amd64
186+
docker run --name [my_container] --volume [local_directory]:[container_directory] -it sswiston/phylo_docker:slim_amd64 /bin/sh
137187
138188
# For Apple Silicon (M1, M2, etc.) computers
139-
docker run --name [my_container] --volume [local_directory]:[container_directory] -it sswiston/phylo_docker:slim_arm64
189+
docker run --name [my_container] --volume [local_directory]:[container_directory] -it sswiston/phylo_docker:slim_arm64 /bin/sh
140190
```
141191
142192
Some parts of this command are directly analogous to the optional settings from the RevBayes GUI.
@@ -151,6 +201,8 @@ You can also run the RevBayes Docker image directly from command line. This will
151201
152202
- `sswiston/phylo_docker:slim_amd64` or `sswiston/phylo_docker:slim_arm64` (hardware-dependent, see above) is the name of the Docker image you want to use.
153203
204+
- `/bin/sh` tells the Docker container to open a new terminal (shell) session when it starts.
205+
154206
Congrats, you are inside the Docker container! You should be able to access all of the programs and files in the container, and also the directory you mounted from your host machine.
155207
156208
4. Navigate to the location of your test script with `cd [filepath]`, using the filepath that you mounted your directory to in Step 3.
@@ -190,7 +242,7 @@ You can use the Docker Desktop GUI to run the RevBayes Docker image (but see cav
190242
191243
9. Another tab on the lefthand side of the screen should be called `containers`. Clicking this option should bring you to a screen showing all of the containers you currently have running.
192244
193-
10. There are two ways to access the container as it is running. The first way is to click on the running container inside the Containers panel, and then click on the Exec tab from the list of tabs at the top of the container menu. The second way is to find the running container inside the Containers panel, and then click on the icon with three vertical dots to the right of the container name. This will open a menu of options. Click on the "Open in terminal" menu item. Clicking this option will take you to the Exec tab, as in the first option. Congrats, you are inside the Docker container! You should be able to access all of the programs and files in the container, and also the directory you mounted from your host machine.
245+
10. There are two ways to access the container as it is running. The first way is to click on the running container inside the Containers panel, and then click on the `Exec` tab from the list of tabs at the top of the container menu. The second way is to find the running container inside the Containers panel, and then click on the icon with three vertical dots to the right of the container name. This will open a menu of options. Click on the "Open in terminal" menu item. Clicking this option will take you to the `Exec` tab, as in the first option. Within the `Exec` tab, there is a blue link that says *"Open in external terminal"*, which allows you to use your own terminal program to control the Docker session. Congrats, you are inside the Docker container! You should be able to access all of the programs and files in the container, and also the directory you mounted from your host machine.
194246
195247
11. Navigate to the location of your test script with `cd [filepath]`, using the filepath that you mounted your directory to in Step 7.
196248

tutorials/geosse/scripts/geosse.Rev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# load TensorPhylo plugin
2-
#loadPlugin("TensorPhylo")
3-
loadPlugin("TensorPhylo","/Users/mlandis/.local/lib/tensorphylo")
2+
loadPlugin("TensorPhylo")
3+
#loadPlugin("TensorPhylo","/Users/mlandis/.local/lib/tensorphylo")
44

55
# FILESYSTEM
66
fp = "./"

tutorials/multifig/scripts/multifig.Rev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# load Tensorphylo plugin
2-
#loadPlugin("TensorPhylo")
3-
loadPlugin("TensorPhylo", "/Users/mlandis/.local/lib/tensorphylo")
2+
loadPlugin("TensorPhylo")
3+
#loadPlugin("TensorPhylo", "/Users/mlandis/.local/lib/tensorphylo")
44

55
##################
66
# ANALYSIS SETUP #

0 commit comments

Comments
 (0)