Debian Codegraph @

my_docs/22/lmod_zoom_mtg_2022_02_08/presentation.tex

raw
1 \documentclass{beamer}
2
3 % You can also use a 16:9 aspect ratio:
4 %\documentclass[aspectratio=169]{beamer}
5 \usetheme{TACC16}
6
7 % It's possible to move the footer to the right:
8 %\usetheme[rightfooter]{TACC16}
9
10 \begin{document}
11 \title[Lmod]{Providing Current Module Data to Hooks}
12 \author{Robert McLay}
13 \date{Feb. 8, 2022}
14
15 % page 1
16 \frame{\titlepage}
17
18
19 % page 2
20 \begin{frame}{Providing Current Module Data to Hooks}
21 \center{\includegraphics[width=.9\textwidth]{[email protected]}}
22 \begin{itemize}
23 \item Here we explore some core concepts in how Lmod works
24 \item The FrameStk: A stack of modules in the load process
25 \item The ModuleTable(MT): The currently loaded modules
26 ($\neq$ frameStk)
27 \item MName: ModuleName objects
28 \end{itemize}
29 \end{frame}
30
31
32 % page 3
33 \begin{frame}{Core Lmod Concept: sn, fullName, version}
34 \begin{itemize}
35 \item The FullName of the module is the shortname/version
36 \item N/V: FullName: gcc/9.4.0: sn: gcc, version: 9.4.0
37 \item C/N/V: FullName: cmplr/gcc/11.2, sn: cmplr/gcc, version: 11.2
38 \item N/V/V: FullName: bowtie/64/22.1, sn: bowtie, version: 64/22.1
39 \item N/V/V: FullName: bio/bowtie/64/22.1, sn: bio/bowtie, version: 64/22.1
40 \end{itemize}
41 \end{frame}
42
43 % page 4
44 \begin{frame}{Core concept: Singleton}
45 \begin{itemize}
46 \item The Lmod code uses the Design Pattern: Singleton
47 \item A singleton will build an object only once
48 \item No matter how many times it is asked for
49 \end{itemize}
50 \end{frame}
51
52 % page 5
53 \begin{frame}{MName: userName $\Rightarrow$ sn, fullName }
54 \begin{itemize}
55 \item {\color{blue}\texttt{module load} \emph{foo}}
56 \item {\color{blue}\emph{foo}} is the userName
57 \item The userName might be an sn or a fullName
58 \item Or somewhere in between for N/V/V
59 \item The MName class builds an mname object that knows sn,
60 fullName, etc
61 \end{itemize}
62 \end{frame}
63
64 % page 6
65 \begin{frame}{FrameStk}
66 \begin{itemize}
67 \item Named borrowed from StackFrame
68 \item It is a stack of mname object that are in the process of
69 being loaded
70 \item It also contains the current ModuleTable
71 \end{itemize}
72 \end{frame}
73
74 % page 7
75 \begin{frame}{ModuleTable A.K.A. mt}
76 \begin{itemize}
77 \item This is a hashtable or dict of the currently loaded modules
78 \item This table is stored in the user environment to store the
79 state
80 \item This is how {\color{blue}\texttt{module load}} can work
81 \item The MT is split into 256 character blocks when saved in
82 user's environment
83 \item And stored as \$\_ModuleTable001\_ ...
84 \item The module properties are stored in mt.
85 \end{itemize}
86 \end{frame}
87
88 % page 7a
89 \begin{frame}[fragile]
90 \frametitle{\texttt{ml --mt}}
91 {\tiny
92 \begin{semiverbatim}
93 \_ModuleTable\_ = \{
94 MTversion = 3,
95 mT = \{
96 mkl = \{
97 fn = "/opt/apps/modulefiles/Core/mkl/mkl.lua",
98 fullName = "mkl/mkl",
99 loadOrder = 1,
100 propT = \{
101 arch = \{
102 gpu = 1,
103 \},
104 \},
105 stackDepth = 0,
106 status = "active",
107 userName = "mkl",
108 wV = "*mkl.*zfinal",
109 \},
110 \},
111 \},
112 \end{semiverbatim}
113 }
114 \end{frame}
115
116 % page 8
117 \begin{frame}{Steps to load a module}
118 \begin{enumerate}
119 \item Convert userName to mname object
120 \item Push mname object onto frameStk stack.
121 \item Get current mt from frameStk
122 \item Add mname to mt and mark as {\color{blue} pending}
123 \item Load current modulefile by evaluating as a lua program
124 \item If no errors then change status in mt to {\color{blue}
125 active} for current module.
126 \item Pop top entry from frameStk
127 \end{enumerate}
128 \end{frame}
129
130 % page 9
131 \begin{frame}{How can size(frameStk) $>$ 1? }
132 \begin{itemize}
133 \item A modulefile can load other modulefiles
134 \item This stack is only as deep as there are pending modules
135 \item Direct user loads have a stack size of 1.
136 \item Dependent loads will have a stack size $>$ 1
137 \item Some sites use this for module tracking
138 \item They only record a modulefile if the stack size is 1.
139 \end{itemize}
140 \end{frame}
141
142 % page 10
143 \begin{frame}{How to get current module data in a hook}
144 \begin{itemize}
145 \item {\color{blue} Pay-off slide}
146 \item Ask for frameStk object from the singleton
147 \item Ask for the current mname object from frameStk
148 \item Ask for the current mt object from frameStk
149 \item Ask for the sn from mname
150 \item Ask mt:haveProperty(sn, propname, propvalue)
151 \end{itemize}
152 \end{frame}
153
154 % page 10a
155 \begin{frame}[fragile]
156 \frametitle{ml --mt}
157 {\tiny
158 \begin{semiverbatim}
159 function M.isVisible(self, modT)
160 local frameStk = require("FrameStk"):singleton()
161 local mname = frameStk:mname()
162 local mt = frameStk:mt()
163 local mpathA = mt:modulePathA()
164 local name = modT.fullName
165 ...
166
167 modT.isVisible = isVisible
168 modT.mname = mname
169 modT.sn = mname:sn()
170 modT.mt = mt
171 hook.apply("isVisibleHook", modT)
172 return modT.isVisible
173 end
174 \end{semiverbatim}
175 }
176 \end{frame}
177
178
179 % page 11
180 \begin{frame}{Side notes}
181 \begin{itemize}
182 \item Note that the mt table is key'ed by sn
183 \item This is why Lmod has the one name rule.
184 \item It is really the one sn rule.
185 \end{itemize}
186 \end{frame}
187
188 % page 12
189 \begin{frame}[fragile]
190 \frametitle{Issue \#554: Interesting Bug in Bash and shell functions}
191 {\tiny
192 \begin{semiverbatim}
193 set_shell_function("_some_spack_func" "\textbackslash
194 local ARG1=\$1\textbackslash
195 if [[ \$ARG1 == {\color{red}[a-z]*} ]]; then\textbackslash
196 echo ...\textbackslash
197 fi\textbackslash
198 ","")
199 \end{semiverbatim}
200 }
201 \begin{itemize}
202 \item This works fine in zsh but not bash
203 \item All bash versions expand [a-z]\** to files in current directory
204 \item I didn't see a way to fix this
205 \item Bash always expands {\color{blue}A='[a-z]\**'}
206 \item Xavier Delaruelle commented on Issue \#554
207 \item He suggested turning off file globbing
208 \end{itemize}
209 \end{frame}
210
211 % page 13
212 \begin{frame}[fragile]
213 \frametitle{Xavier Delaruelle's Two Ideas}
214 {\tiny
215 \begin{semiverbatim}
216 # Before eval
217 _mlshopt="f";
218 case "$-" in
219 *f*) unset _mlshopt;;
220 esac;
221 if [ -n "${_mlshopt:-}" ]; then
222 set -$_mlshopt;
223 fi;
224
225 # After eval:
226 if [ -n "${_mlshopt:-}" ]; then
227 set +$_mlshopt;
228 fi;
229 unset _mlshopt;
230 \end{semiverbatim}
231 }
232 \begin{itemize}
233 \item Use \$- to know if user already has globbing off
234 \item If "f" is in string: File Globbing on
235 \item set -f turns File Globbing off, adds f to \$-
236 \item set +f turns File Globbing on, removes f from \$-
237 \end{itemize}
238 \end{frame}
239
240
241 % page 14
242 \begin{frame}{Where do you have to turn off file globbing }
243 \begin{itemize}
244 \item I thought that you could have the generated Lmod shell
245 commands disable file globbing
246 \item This \emph{does not work!}
247 \item Instead the disabling of file globbing has to be part of the module
248 command definition
249 \item Next version of Lmod's module will automatically turn off
250 shell debugging when doing: set -xv
251 \end{itemize}
252 \end{frame}
253
254 % page 15
255 \begin{frame}[fragile]
256 \frametitle{Updated module command for bash like shells}
257 {\tiny
258 \begin{semiverbatim}
259 module()
260 \{
261 ############################################################
262 # Silence shell debug UNLESS $LMOD\_SH\_DBG\_ON has a value
263 ...
264
265 ############################################################
266 # turn off file globbing if it is not already off
267 ...
268
269 ############################################################
270 # Run Lmod and eval results
271 eval $($LMOD\_CMD bash "$@") && eval $(${LMOD\_SETTARG\_CMD:-:} -s sh)
272 \_\_lmod_my_status=$?
273
274 ############################################################
275 # turn on file globbing for users who want it.
276 ...
277
278 ############################################################
279 # Un-silence shell debug after module command
280 ...
281
282 return $\_\_lmod_my_status
283 \}
284 \end{semiverbatim}
285 }
286 \end{frame}
287
288 % page 16
289 \begin{frame}{Next Topic}
290 \begin{itemize}
291 \item Lmod Testing System
292 \item Monday March 1st at 15:30 UTC (9:30am US Central)
293 \end{itemize}
294 \end{frame}
295
296 % page 17
297 \begin{frame}{Future Topics}
298 \begin{itemize}
299 \item More internals of Lmod?
300 \item Guest Presentation of special issues?
301 \end{itemize}
302 \end{frame}
303
304 \end{document}