Debian Codegraph @

my_docs/22/lmod_zoom_mtg_2022_11_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 %% page
11 %\begin{frame}{}
12 % \begin{itemize}
13 % \item
14 % \end{itemize}
15 %\end{frame}
16 %
17 %% page
18 %\begin{frame}[fragile]
19 % \frametitle{}
20 % {\tiny
21 % \begin{semiverbatim}
22 % \end{semiverbatim}
23 %}
24 % \begin{itemize}
25 % \item
26 % \end{itemize}
27 %
28 %\end{frame}
29
30 \begin{document}
31 \title[Lmod]{How Lmod processes TCL modulefiles}
32 \author{Robert McLay}
33 \date{November 8, 2022}
34
35 % page 1
36 \frame{\titlepage}
37
38
39 % page 2
40 \begin{frame}{Outline}
41 \center{\includegraphics[width=.9\textwidth]{[email protected]}}
42 \begin{itemize}
43 \item Original Idea was just to support Lua based modules
44 \item Hard to get sites to translate their existing modules
45 (including TACC!)
46 \item So how to support TCL modulefiles?
47 \item What strategies are possible?
48 \item What technique does Lmod use
49 \item Why it is never going to be perfect.
50 \end{itemize}
51 \end{frame}
52
53 % page 3
54 \begin{frame}{How could TCL modulefiles be supported?}
55 \begin{itemize}
56 \item Could write a TCL interpreter in Lua
57 \item Ugh!, too much work, Hard to maintain, Hard to get right
58 \item Could rewrite much of the Lmod lua code in TCL
59 \item Ugh! (same reasons!)
60 \item Try something else
61 \end{itemize}
62 \end{frame}
63
64 % page 4
65 \begin{frame}{Something good enough}
66 \begin{itemize}
67 \item I tried something that I could do
68 \item Create (really steal) a pure TCL module interpreter
69 \item Convert it to work for Lmod.
70 \item Called tcl2lua.tcl
71 \end{itemize}
72 \end{frame}
73
74
75 % page 5
76 \begin{frame}{Where tcl2lua.tcl cam from}
77 \begin{itemize}
78 \item It was the freely available pure TCL env. module code
79 \item This was before Xavier took over Tmod
80 \item It was simple enough to understand and convert.
81 \end{itemize}
82 \end{frame}
83
84 % page 6
85 \begin{frame}{TCL is one of my least favorite languages}
86 \begin{itemize}
87 \item Its parser is very line-oriented
88 \item So it is very picky about what goes where
89 \item My intuition about the language is almost always wrong.
90 \end{itemize}
91 \end{frame}
92
93 % page 7
94 \begin{frame}{Surprising help from stackoverflow.com}
95 \begin{itemize}
96 \item I have had many questions about how TCL works
97 \item I am always shocked that my TCL question would get answered
98 \item Grateful, but amazed!
99 \end{itemize}
100 \end{frame}
101
102 % page 8
103 \begin{frame}{Questions for stackoverflow.com}
104 \begin{itemize}
105 \item How does the puts command work?
106 \item How break works?
107 \item How the child interpreter works
108 \end{itemize}
109 \end{frame}
110
111 % page 9
112 \begin{frame}{How tcl2lua.tcl works}
113 \begin{itemize}
114 \item Let the TCL interpreter evaluate regular TCL commands
115 \item Convert the TCL setenv, prepend-path etc
116 \item $\Rightarrow$ into Lua setenv(), prepend\_path() strings
117 \item This lua output is then interpreted by Lmod as a Lua module
118 \item This works very well most of the time
119 \item However ...
120 \end{itemize}
121 \end{frame}
122
123 % page 10
124 \begin{frame}[fragile]
125 \frametitle{When things go awry}
126 \begin{itemize}
127 \item Suppose you have TCL modules \textbf{Centos} and \textbf{B}
128 \end{itemize}
129 {\tiny
130 \begin{semiverbatim}
131 Centos::
132
133 #%Module
134 setenv SYSTEM\_NAME Centos
135
136 And B::
137
138 #%Module
139 module load Centos
140
141 if \{ \$env(SYSTEM\_NAME) == "Centos" \} \{
142 # do something
143 \}
144
145 \end{semiverbatim}
146 }
147 \end{frame}
148
149 % page 11
150 \begin{frame}[fragile]
151 \frametitle{Converting the TCL \textbf{B} into Lua}
152 {\tiny
153 \begin{semiverbatim}
154 load("Centos")
155 LmodError("can't read \"env(SYSTEM\_NAME)\": no such variable")
156 \end{semiverbatim}
157 }
158 \begin{itemize}
159 \item Trouble: the TCL \textbf{load} command $\Rightarrow$
160 \texttt{load("Centos")}
161 \item Cannot get the TCL load command to be evaluated before the
162 TCL if block
163 \end{itemize}
164
165 \end{frame}
166
167
168 % page 12
169 \begin{frame}{The best solutions would be: }
170 \begin{itemize}
171 \item In this case use TCL code to get the name of the Linux OS
172 \item Or use lsb\_release inside the \textbf{B} modulefile
173 \item Or translate the TCL \texttt{B} module into Lua
174 \item Note that you can have both a TCL B/1.0 module \textbf{and}
175 a B/1.0.lua module in the same directory
176 \item Lmod will always chose the Lua modulefile over the TCL one.
177 \item Tmod will ignore the *.lua file (no \#\%Module start line)
178 \end{itemize}
179 \end{frame}
180
181 % page 13
182 \begin{frame}[fragile]
183 \frametitle{The \textbf{B} translated into Lua}
184 {\tiny
185 \begin{semiverbatim}
186 load("Centos")
187 if (os.getenv("SYSTEM\_NAME") == "Centos") then
188 -- Do something
189 end
190 \end{semiverbatim}
191 }
192 \begin{itemize}
193 \item Note that the Centos module DO NOT need to be translated
194 into Lua.
195 \end{itemize}
196
197 \end{frame}
198
199 % page 15
200 \begin{frame}{Next time}
201 \begin{itemize}
202 \item Lmod 8.0+ brought many improvements to TCL module support
203 \item TCL break command
204 \item Optional Integration of TCL interpreter into Lmod (saves
205 time)
206 \item Support for is-loaded
207 \item Support for is-avail and why I resisted supporting that for
208 TCL modulefiles for so long
209 \item Special features of setenv and pushenv in TCL
210 \item How tcl2lua.tcl supports the \textbf{puts} command
211 \item New bugs found when integrating the TCL interpreter into Lmod
212 \end{itemize}
213 \end{frame}
214
215
216
217 % page 25
218 \begin{frame}{Future Topics}
219 \begin{itemize}
220 \item Next Meeting: December 6th 9:30 US Central (15:30 UTC)
221 \end{itemize}
222 \end{frame}
223
224 \end{document}