The simulation launcher allows to link Lagun to a simulator. To do this, you first need to configure this link to the simulator. Several examples are provided in the Lagun gitlab repository.
In this post, we’ll look at how to link Lagun and Um-bridge, each running within a container.
Step 1 - Create a network
How do you allow one container to talk to another? The answer is networking. If you place the two containers on the same network, they can talk to each other.
https://docs.docker.com/get-started/07_multi_container/
So the first step is to create a network (let’s call it mynetwork
). In a command line interpreter, execute the command:
docker network create mynetwork
Step 2 - Start a Um-Bridge model
Let’s start the tsunami model like described in the Um-Bridge documentation. In a command line interpreter, run the model as you normally would, but add two options to specify:
- the network to connect to;
- an hostname alias for this container (let’s called it
tsunami
).
docker run --network mynetwork --network-alias tsunami -it -p 4242:4242 linusseelinger/model-exahype-tsunami
Now the model is running, ready to be called by the simulations launcher.
Step 3 - Customize the Lagun simulator image
In a command line interpreter:
-
Run the simulations launcher image to modify.
docker run -d detocs/lagun-simulations-launcher:1.1.0-I-b2-alpine
Should return the
id
of the run container (for examplec49d4120a7a0a62ebe95adc82bb91c92dd12400064be9cc53ac18ffe317c698f
). -
Execute the command to open a shell on this container (replace the
id
by yours):docker exec -it c49d4120a7a0a62ebe95adc82bb91c92dd12400064be9cc53ac18ffe317c698f sh
-
In this shell, execute the command to install the R package
umbridge
:R -e "install.packages('umbridge', repos = 'http://cloud.r-project.org')"
The installation should end with a line saying
DONE (umbridge)
(warnings may follow). -
Modify the simulator configuration file RSimulator.sh dedicated to Um-Bridge in the
simulator-examples
directory (localhost
is to replace by the aliastsunami
defined in step 2)#!/bin/sh - Rscript --vanilla lagunClient.R http://localhost:4242 paramFile.txt + Rscript --vanilla lagunClient.R http://tsunami:4242 paramFile.txt
-
Exit the shell opened on this container (run the command
exit
). -
Commit this container with these changes into a new image (let’s call it
launcher-with-umbridge
; don’t forget to replaceid
by yours):docker commit c49d4120a7a0a62ebe95adc82bb91c92dd12400064be9cc53ac18ffe317c698f launcher-with-umbridge
Step 4 - Run your modified Simulations Launcher image
In a command line interpreter, run your new image launcher-with-umbridge
as you normally would, but add an option to specify the network to connect to:
docker run -dp 0.0.0.0:3000:3000 `
--network mynetwork `
--mount type=bind,src="$(pwd)/runningDir",target=/runningDir `
--mount type=bind,src="$(pwd)/simulator-examples",target=/simulator-examples `
launcher-with-umbridge
Step 5 - Import the Um-Bridge simulator configuration
Open your simulations launcher client (located by default at http://localhost:3000/) and import the launcher-server-linux.json provided in the simulator-examples
directory.
A new simulator called « UM-Bridge » is now available in Lagun!