ML beam test PID Meetings » History » Version 29
Richard Trotta, 05/30/2024 12:04 PM
1 | 1 | Richard Trotta | {{>toc}} |
---|---|---|---|
2 | |||
3 | h1. ML beam test PID Meetings |
||
4 | |||
5 | 3 | Richard Trotta | --- |
6 | |||
7 | 1 | Richard Trotta | h2. Summer 2024 |
8 | 4 | Richard Trotta | |
9 | --- |
||
10 | |||
11 | 25 | Richard Trotta | h3. May 28th, 2024 |
12 | 1 | Richard Trotta | |
13 | * Darren ran with Python3.9 |
||
14 | * Docker (containerization) Definition |
||
15 | ** Containerization is a technology that allows developers to package and run applications along with all their dependencies in isolated environments called containers. This ensures that the application runs consistently across different computing environments, from a developer's laptop to testing, staging, and production. |
||
16 | ** Docker is a popular platform that simplifies containerization. It provides tools to create, deploy, and manage containers. With Docker, developers can write code locally, share their work with colleagues, and deploy to production in a seamless and efficient manner. Docker containers are lightweight, fast, and portable, making them ideal for modern software development and deployment. |
||
17 | 9 | Richard Trotta | |
18 | 17 | Richard Trotta | * "A Crash Course for Summer Research":https://drive.google.com/file/d/1-TPLo5VGSwCUDjqj_j4g--p4FbBgYHbw/view?usp=sharing\ |
19 | * "GitHub and Python Introduction":https://github.com/trottar/UVA_summer_students |
||
20 | 18 | Richard Trotta | ** Navigate to "python_tutorials":https://github.com/trottar/UVA_summer_students/tree/master/python_tutorials and read through the two html files ("Introduction":https://github.com/trottar/UVA_summer_students/blob/master/python_tutorials/Introduction.ipynb and "python_tutorial_2":https://github.com/trottar/UVA_summer_students/blob/master/python_tutorials/python_tutorial_2.ipynb) |
21 | *** Note, these are html files so you'll need |
||
22 | 8 | Richard Trotta | |
23 | h4. Near-term Goals |
||
24 | |||
25 | # Setup Linux Subsystem for Windows |
||
26 | # Fork the ML Beam Testing GitHub repository |
||
27 | # Containerize ML Beam Testing GitHub repository with Docker |
||
28 | 5 | Richard Trotta | |
29 | 14 | Richard Trotta | h4. Homework |
30 | |||
31 | 16 | Richard Trotta | * "Read chapters 0-3 and finish exercises":https://drive.google.com/file/d/1-TPLo5VGSwCUDjqj_j4g--p4FbBgYHbw/view?usp=sharing |
32 | 14 | Richard Trotta | |
33 | 3 | Richard Trotta | --- |
34 | 19 | Richard Trotta | |
35 | 25 | Richard Trotta | h3. May 29th, 2024 |
36 | 19 | Richard Trotta | |
37 | h4. Setting Up Jupyter Notebooks in Docker |
||
38 | |||
39 | # Create a directory to store, build, and run Docker container |
||
40 | <pre><code class="bash"> |
||
41 | cd /path/to/directory |
||
42 | mkdir beamtest_dir |
||
43 | 20 | Richard Trotta | cd beamtest_dir |
44 | </code></pre> |
||
45 | 21 | Richard Trotta | # Once in the new directory, create a Dockerfile |
46 | 20 | Richard Trotta | <pre><code class="bash"> |
47 | touch Dockerfile |
||
48 | </code></pre> |
||
49 | 21 | Richard Trotta | # Using the text editor (e.g., vim, gedit, or emacs) of your choice, edit the Dockerfile with the following information |
50 | 20 | Richard Trotta | <pre><code class="bash"> |
51 | # Use the official Python 3.9 image as the base image |
||
52 | FROM python:3.9 |
||
53 | |||
54 | # Install Jupyter Notebook and other dependencies |
||
55 | RUN pip install --no-cache-dir jupyter |
||
56 | |||
57 | # Create a working directory |
||
58 | WORKDIR /workspace |
||
59 | |||
60 | # Expose the Jupyter Notebook port |
||
61 | EXPOSE 8888 |
||
62 | |||
63 | # Set the default command to start Jupyter Notebook |
||
64 | 1 | Richard Trotta | CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root"] |
65 | </code></pre> |
||
66 | 21 | Richard Trotta | # Build the Docker image (e.g., helloworld) |
67 | <pre><code class="bash"> |
||
68 | docker build -t helloworld . |
||
69 | </code></pre> |
||
70 | # Run the Docker container |
||
71 | </code></pre> |
||
72 | <pre><code class="bash"> |
||
73 | docker run -p 8888:8888 helloworld |
||
74 | </code></pre> |
||
75 | # Jupyter Notebook is now running. Navigate to a browser and type in either |
||
76 | 23 | Richard Trotta | |
77 | 21 | Richard Trotta | * The custom token authorization screen</code></pre> |
78 | <pre><code class="bash"> |
||
79 | http://localhost:8888 |
||
80 | </code></pre> |
||
81 | 22 | Richard Trotta | |
82 | 21 | Richard Trotta | * To bypass the token screen, copy/paste the URL that splashes in the terminal into your browser |
83 | 24 | Richard Trotta | |
84 | h4. Near-term Goals |
||
85 | |||
86 | # Try and get the "python tutorial":https://github.com/trottar/UVA_summer_students Jupyter notebooks working in a container. |
||
87 | |||
88 | h4. Homework |
||
89 | |||
90 | * "Read chapters 0-3 and finish exercises":https://drive.google.com/file/d/1-TPLo5VGSwCUDjqj_j4g--p4FbBgYHbw/view?usp=sharing |
||
91 | 27 | Richard Trotta | |
92 | --- |
||
93 | |||
94 | h3. May 30th, 2024 |
||
95 | |||
96 | h4. Setting Up Bash Script for Running Docker |
||
97 | |||
98 | 28 | Richard Trotta | # Create a bash script |
99 | <pre><code class="bash"> |
||
100 | touch run_docker.sh |
||
101 | </code></pre> |
||
102 | 29 | Richard Trotta | # Using the text editor (e.g., vim, gedit, or emacs) of your choice, edit run_docker.sh |
103 | <pre><code class="bash"> |
||
104 | #!/bin/bash |
||
105 | 1 | Richard Trotta | |
106 | 29 | Richard Trotta | # Build docker image ($1 is the first bash script argument) |
107 | docker build -t $1 |
||
108 | |||
109 | # Run the docker container (renaming it with the '_container' string) |
||
110 | docker run -p 8888:8888 --name "${1}_container" $1 |
||
111 | </code></pre> |
||
112 | |||
113 | # Adjust permissions with "chmod":https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/how-permissions-chmod-with-numbers-command-explained-777-rwx-unix to allow script execution |
||
114 | <pre><code class="bash"> |
||
115 | chmod 755 run_docker.sh |
||
116 | </code></pre> |
||
117 | |||
118 | h4. Setting Up Bash Script for Running Docker |
||
119 | 28 | Richard Trotta | |
120 | h4. Useful Docker Commands |
||
121 | 27 | Richard Trotta | |
122 | * To see all docker images |
||
123 | <pre><code class="bash"> |
||
124 | docker images |
||
125 | </code></pre> |
||
126 | * To see all docker containers running |
||
127 | <pre><code class="bash"> |
||
128 | docker ps |
||
129 | </code></pre> |
||
130 | * To end specific docker container |
||
131 | <pre><code class="bash"> |
||
132 | docker end <container_id> |
||
133 | </code></pre> |
||
134 | * To end all docker container |
||
135 | <pre><code class="bash"> |
||
136 | docker end $(docker ps -q) |
||
137 | </code></pre> |