Skip to content

Commit

Permalink
03: Add root and python container instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
katilp committed May 14, 2024
1 parent 8bdae8f commit 01d93f7
Showing 1 changed file with 67 additions and 18 deletions.
85 changes: 67 additions & 18 deletions episodes/03-docker-for-cms-opendata.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Three types of container images are provided: [one with the CMS software (CMSSW)

You will only need the CMSSW container, if you want to access the CMS data in the MiniAOD format (you will learn about them later). Access to it requires CMSSW software that you will not be able to install on your own computer.

We will be using the CMS data the NanoAOD format and access to it does not require any CMS-specifc software. The two containers are provided to make setting up and using ROOT and/or python libraries easier for you for this tutorial, but if you wish, you can also install them on your computer.
During the workshop hands-on lessons, we will be using the CMS data the NanoAOD format and access to it does not require any CMS-specifc software. Two containers are provided to make setting up and using ROOT and/or python libraries easier for you for this tutorial, but if you wish, you can also install them on your computer.

All container images come with [VNC](https://gitlab.cern.ch/cms-cloud/cmssw-docker-opendata/-/blob/master/README.md#use-vnc) for the graphical use interface. It opens directly in a browser window. Optionally, you can also connect to the VNC server of the container using a VNC viewer (VNC viewer (TigerVNC, RealVNC, TightVNC, OSX built-in VNC viewer, etc.) installed on your local machine, but only the browser option for which no additional tools are needed is described in these instructions. On native Linux, you can also use X11-forwarding.

Expand All @@ -44,47 +44,96 @@ The first time you start a container, a docker image file gets downloaded from a

The containers do not have modern editors and it is expected that you mount your working directory from the local computer into the container, and use your normal editor for editing the files. Note that all your compiling and executing still has to be done in the Docker container!

First, before you start up your container, create a local directory where you will be doing your code development. In the example below, it is called cms_open_data_work and it will live in the $HOME directory. You may choose a different location and a shorter directory name if you like.
First, before you start up your container, create a local directory where you will be doing your code development. In the examples below, it is called `cms_open_data_python` and `cms_open_data_root`, respectively, and the variable will record your working directory path. You may choose a different location and a shorter directory name if you like.

### Python tools container

Create the shared directory in your working area:

::: group-tab
```bash
export workpath=$PWD
mkdir cms_open_data_work
chmod -R 777 cms_open_data_python
```

### Windows WSL
Start the container with

Run ...
```bash
docker run -it --name my_python -P -p 8888:8888 -v ${workpath}/cms_open_data_python:/code gitlab-registry.cern.ch/cms-cloud/python-vnc:python3.10.5

### Mac
```

Run ...
You will get a container prompt similar this:

### Linux
```output
cmsusr@4fa5ac484d6f:/code$
```

X11
This is a bash shell and you can see the files in your shared area.

:::
You can now open a jupyter lab from the container prompt with

```bash
jupyter-lab --ip=0.0.0.0 --no-browser
```

and open the link that is printed out in the message.

Click on the Jupyter notebook icon to open a new notebook.


:::::::::::::::::::::::::::::: callout

## Permission denied?

If a window with "Error Permission denied: Untitled.ipynb" pops up, you most likely forgot to define the path variable, to create the shared directory or to change its permissions. Exit the jupyter lab with Control-C and confirm with y, then type `exit` to stop the container. Remove the container with

```bash
docker rm my_python
```

and now start all over from [the start](#python-tools-container).

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

### Root tools container

::: group-tab
Create the shared directory in your working area:

### Windows WSL
```bash
export workpath=$PWD
mkdir cms_open_data_work
chmod -R 777 cms_open_data_root
```

4
Then start the container:

### Mac
::: tab

5
### Windows WSL, Mac and Linux without X11-forwarding

### Linux
```bash
docker run -it --name my_root -P -p 5901:5901 -p 6080:6080 -v ${workpath}/cms_open_data_root:/code gitlab-registry.cern.ch/cms-cloud/root-vnc:latest
```

6
For graphics, use VNC that is installed in the container and start the graphics windows with `start_vnc`. Open the browser window in the address given at the start message (http://127.0.0.1:6080/vnc.html) with the default VNC password is `cms.cern`. It shows an empty screen to start with and all graphics will pop up there.

Check warning on line 119 in episodes/03-docker-for-cms-opendata.md

View workflow job for this annotation

GitHub Actions / Build Full Site

[needs HTTPS]: [http://127.0.0.1:6080/vnc.html](http://127.0.0.1:6080/vnc.html)

:::
Type `exit` to leave the container, and if you have started VNC, stop it first:

```bash
stop_vnc
exit
```

### Linux using X11-forwarding

```bash
docker run -it --name my_root --net=host --env="DISPLAY" -v $HOME/.Xauthority:/home/cmsusr/.Xauthority:rw -v ${workpath}/cms_open_data_root:/code gitlab-registry.cern.ch/cms-cloud/root-vnc:latest
```

For graphics, X11-forwarding to your host is used.

:::



Expand Down

0 comments on commit 01d93f7

Please sign in to comment.