| 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]{Lmod tools to check module syntax} |
| 32 |
\author{Robert McLay} |
| 33 |
\date{February 14, 2023} |
| 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 How to check module syntax when building an RPM or other |
| 44 |
software packages |
| 45 |
\item How to check your sites' entire module tree. |
| 46 |
\end{itemize} |
| 47 |
\end{frame} |
| 48 |
|
| 49 |
% page 3 |
| 50 |
\begin{frame}{Checking Modulefile Syntax} |
| 51 |
\begin{itemize} |
| 52 |
\item We want to check the syntax |
| 53 |
\item Not the action! |
| 54 |
\item We ignore the actions of loads(), depends\_on() ... |
| 55 |
\item How to evaluate all the syntax but not the action? |
| 56 |
\end{itemize} |
| 57 |
\end{frame} |
| 58 |
|
| 59 |
% page 4 |
| 60 |
\begin{frame}{Quick Review: How Lmod evaluates modulefile functions} |
| 61 |
\begin{itemize} |
| 62 |
\item Remember that commands like \texttt{setenv("ABC","3")} do |
| 63 |
different things |
| 64 |
\item On module load it sets \texttt{ABC} to \texttt{3} |
| 65 |
\item On module unload it unsets \texttt{ABC} |
| 66 |
\item On module show it prints \texttt{setenv("ABC","3")} |
| 67 |
\end{itemize} |
| 68 |
\end{frame} |
| 69 |
|
| 70 |
% page 5 |
| 71 |
\begin{frame}[fragile] |
| 72 |
\frametitle{src/modfuncs.lua: setenv()} |
| 73 |
\begin{itemize} |
| 74 |
\item Almost all modulefile function work like setenv() |
| 75 |
\item They check the syntax |
| 76 |
\item Then they call a member function in the MainControl Class |
| 77 |
\item The \texttt{mcp} variable is global MainControl object |
| 78 |
\item \texttt{mcp} controls what mode Lmod is in. |
| 79 |
\end{itemize} |
| 80 |
{\tiny |
| 81 |
\begin{semiverbatim} |
| 82 |
function setenv(...) |
| 83 |
if (not l_validateArgsWithValue("setenv",...)) then |
| 84 |
return |
| 85 |
end |
| 86 |
mcp:setenv(...) |
| 87 |
return |
| 88 |
end |
| 89 |
\end{semiverbatim} |
| 90 |
} |
| 91 |
\end{frame} |
| 92 |
|
| 93 |
% page 6 |
| 94 |
\begin{frame}{Controlling Lmod Evaluation Mode} |
| 95 |
\begin{itemize} |
| 96 |
\item The \texttt{mcp} object acts as a big switchboard. |
| 97 |
\item When loading: \texttt{mcp} constructs derived class |
| 98 |
MC\_Load object. |
| 99 |
\item When unloading: \texttt{mcp} constructs derived class |
| 100 |
MC\_Unload object. |
| 101 |
\item When checking syntax:\texttt{mcp} constructs derived class |
| 102 |
MC\_CheckSyntax object. |
| 103 |
\end{itemize} |
| 104 |
\end{frame} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
% page 7 |
| 109 |
\begin{frame}[fragile] |
| 110 |
\frametitle{src/MC\_Load.lua} |
| 111 |
{\tiny |
| 112 |
\begin{semiverbatim} |
| 113 |
M.load = MainControl.load |
| 114 |
M.myModuleName = MainControl.myModuleName |
| 115 |
M.prepend\_path = MainControl.prepend\_path |
| 116 |
M.prereq = MainControl.prereq |
| 117 |
M.setenv = MainControl.setenv |
| 118 |
M.set\_alias = MainControl.set\_alias |
| 119 |
M.unload = MainControl.unload |
| 120 |
M.unsetenv = MainControl.unsetenv |
| 121 |
\end{semiverbatim} |
| 122 |
} |
| 123 |
\begin{itemize} |
| 124 |
\item These are the normal mapping when loading |
| 125 |
\end{itemize} |
| 126 |
|
| 127 |
\end{frame} |
| 128 |
|
| 129 |
% page 8 |
| 130 |
\begin{frame}[fragile] |
| 131 |
\frametitle{src/MC\_Unload.lua} |
| 132 |
{\tiny |
| 133 |
\begin{semiverbatim} |
| 134 |
M.load = MainControl.unload |
| 135 |
M.myModuleName = MainControl.myModuleName |
| 136 |
M.prepend\_path = MainControl.remove\_path\_first |
| 137 |
M.prereq = MainControl.quiet |
| 138 |
M.setenv = MainControl.unsetenv |
| 139 |
M.set\_alias = MainControl.unset\_alias |
| 140 |
M.unload = MainControl.unload |
| 141 |
M.unsetenv = MainControl.quiet |
| 142 |
\end{semiverbatim} |
| 143 |
} |
| 144 |
\begin{itemize} |
| 145 |
\item These are the normal mapping when unloading |
| 146 |
\end{itemize} |
| 147 |
\end{frame} |
| 148 |
|
| 149 |
% page 9 |
| 150 |
\begin{frame}[fragile] |
| 151 |
\frametitle{src/MC\_CheckSyntax.Lua} |
| 152 |
{\tiny |
| 153 |
\begin{semiverbatim} |
| 154 |
M.load = MainControl.load |
| 155 |
M.myModuleName = MainControl.myModuleName |
| 156 |
M.prepend\_path = MainControl.prepend\_path |
| 157 |
M.prereq = MainControl.quiet |
| 158 |
M.setenv = MainControl.setenv |
| 159 |
M.set\_alias = MainControl.set\_alias |
| 160 |
M.unload = MainControl.quiet |
| 161 |
M.unsetenv = MainControl.unsetenv |
| 162 |
\end{semiverbatim} |
| 163 |
} |
| 164 |
\begin{itemize} |
| 165 |
\item See that the actions of prereq() are ignored |
| 166 |
\item This way actions outside a module are ignored |
| 167 |
\item The syntax of all commands are checked. |
| 168 |
\item \texttt{MainControl.load} is a special case |
| 169 |
\end{itemize} |
| 170 |
|
| 171 |
\end{frame} |
| 172 |
|
| 173 |
% page 10 |
| 174 |
\begin{frame}[fragile] |
| 175 |
\frametitle{\texttt{MainControl.load} is a special case} |
| 176 |
\begin{itemize} |
| 177 |
\item Loading the module under test must use it |
| 178 |
\item So load\_usr() function has this test |
| 179 |
\item This prevent module loading other modules |
| 180 |
\item Because the frameStk count will be $>$ 1. |
| 181 |
\end{itemize} |
| 182 |
{\tiny |
| 183 |
\begin{semiverbatim} |
| 184 |
function M.load_usr(self, mA) |
| 185 |
local frameStk = FrameStk:singleton() |
| 186 |
if (checkSyntaxMode() and frameStk:count() > 1) then |
| 187 |
return {} |
| 188 |
end |
| 189 |
|
| 190 |
l_registerUserLoads(mA) |
| 191 |
local a = self:load(mA) |
| 192 |
return a |
| 193 |
end |
| 194 |
\end{semiverbatim} |
| 195 |
} |
| 196 |
|
| 197 |
\end{frame} |
| 198 |
|
| 199 |
% page 11 |
| 200 |
\begin{frame}[fragile] |
| 201 |
\frametitle{\texttt{module --checkSyntax load bad/1.0}} |
| 202 |
{\tiny |
| 203 |
\begin{semiverbatim} |
| 204 |
\$ cat bad/1.0.lua |
| 205 |
setenv("ONE") |
| 206 |
|
| 207 |
\$ module --checkSyntax load bad |
| 208 |
Lmod has detected the following error: setenv("ONE") is not valid; |
| 209 |
a value is required. |
| 210 |
While processing the following module(s): |
| 211 |
Module fullname Module Filename |
| 212 |
--------------- --------------- |
| 213 |
bad/1.0 /home/user/myModules/bad/1.0.lua |
| 214 |
|
| 215 |
\end{semiverbatim} |
| 216 |
} |
| 217 |
\begin{itemize} |
| 218 |
\item We here at TACC use this when building module files in an RPM |
| 219 |
*.spec file |
| 220 |
\item Other build tools might find this useful |
| 221 |
\end{itemize} |
| 222 |
\end{frame} |
| 223 |
|
| 224 |
|
| 225 |
% page 12 |
| 226 |
\begin{frame}{New command check\_module\_tree\_syntax} |
| 227 |
\begin{itemize} |
| 228 |
\item I wanted a way to check every modulefile in a site's tree. |
| 229 |
\item The command \texttt{module spider} used to do that. |
| 230 |
\item But sending site error to user is not a good idea. |
| 231 |
\end{itemize} |
| 232 |
\end{frame} |
| 233 |
|
| 234 |
% page 13 |
| 235 |
\begin{frame}{New command check\_module\_tree\_syntax (II)} |
| 236 |
\begin{itemize} |
| 237 |
\item Site wanted to know when module directory had multiple files |
| 238 |
marking a default |
| 239 |
\item There are upto 4 ways to do this in a modulefile directory |
| 240 |
\begin{enumerate} |
| 241 |
\item a default symlink |
| 242 |
\item a .modulerc.lua file |
| 243 |
\item a .modulerc file |
| 244 |
\item a .version file |
| 245 |
\end{enumerate} |
| 246 |
\item The priority is in this order. |
| 247 |
\end{itemize} |
| 248 |
\end{frame} |
| 249 |
|
| 250 |
% page 14 |
| 251 |
\begin{frame}{History} |
| 252 |
\begin{itemize} |
| 253 |
\item The site wanted to report to the user when this happened. |
| 254 |
\item I try hard not to report site errors to users. |
| 255 |
\item After all what are they suppose to do with this info? |
| 256 |
\item So I modified \texttt{\$LMOD\_DIR/spider} to walk the module |
| 257 |
tree. |
| 258 |
\item To make \texttt{\$LMOD\_DIR/check\_module\_tree\_syntax} |
| 259 |
\item This reports both syntax error/warning and duplicate marked |
| 260 |
default files in a modulefile directory. |
| 261 |
\item This command uses the MC\_CheckSyntax mode to eval each modulefiles. |
| 262 |
\end{itemize} |
| 263 |
\end{frame} |
| 264 |
|
| 265 |
% page 15 |
| 266 |
\begin{frame}{Changes to spider cache format} |
| 267 |
\begin{itemize} |
| 268 |
\item Added defaultA to remember all marked defaults in directory |
| 269 |
\item This array is process to use the highest priority marked |
| 270 |
default file. |
| 271 |
\item The old format just kept the highest priority marked default |
| 272 |
file in defaultT. |
| 273 |
\end{itemize} |
| 274 |
\end{frame} |
| 275 |
|
| 276 |
% page 16 |
| 277 |
\begin{frame}[fragile] |
| 278 |
\frametitle{Changes to spiderT.lua} |
| 279 |
{\tiny |
| 280 |
\begin{semiverbatim} |
| 281 |
["ProjectDIR/rt/ck_mtree_syntax/mf"] = \{ |
| 282 |
A = \{{\color{blue} |
| 283 |
defaultA = \{ |
| 284 |
\{ |
| 285 |
barefn = "default", |
| 286 |
defaultIdx = 1, |
| 287 |
fn = "ProjectDIR/rt/ck_mtree_syntax/mf/A/default", |
| 288 |
... |
| 289 |
\}, |
| 290 |
\{ |
| 291 |
barefn = ".version", |
| 292 |
defaultIdx = 4, |
| 293 |
fn = "ProjectDIR/rt/ck_mtree_syntax/mf/A/.version", |
| 294 |
... |
| 295 |
\}, |
| 296 |
\},} |
| 297 |
defaultT = \{ |
| 298 |
barefn = "default", |
| 299 |
defaultIdx = 1, |
| 300 |
fn = "ProjectDIR/rt/ck_mtree_syntax/mf/A/default", |
| 301 |
... |
| 302 |
\}, |
| 303 |
\end{semiverbatim} |
| 304 |
} |
| 305 |
\end{frame} |
| 306 |
|
| 307 |
% page 17 |
| 308 |
\begin{frame}[fragile] |
| 309 |
\frametitle{Example results} |
| 310 |
{\tiny |
| 311 |
\begin{semiverbatim} |
| 312 |
The following directories have more than one marked default file: |
| 313 |
----------------------------------------------------------------- |
| 314 |
/home/user/w/lmod/rt/ck_mtree_syntax/mf/A |
| 315 |
|
| 316 |
|
| 317 |
The following modulefile(s) have syntax errors: |
| 318 |
----------------------------------------------- |
| 319 |
ModuleName: A/1.0, Fn: /mf/A/1.0.lua |
| 320 |
Error: [string "setenv("MY_VERSION", myModuleVersion())..."]:2: unexpected symbol near '#' |
| 321 |
ModuleName: A/2.0, Fn: /mf/A/2.0 |
| 322 |
Error: /mf/A/2.0: (A/2.0): invalid command name "nonExistantCmd" |
| 323 |
ModuleName: hashrf/6.0.1, Fn: /mf/hashrf/6.0.1.lua |
| 324 |
Error: [string "local name = "hashrf"..."]:16: attempt to call a nil value (global 'WTF') |
| 325 |
ModuleName: papi/4.4.0, Fn: /mf/papi/4.4.0.lua |
| 326 |
Error: command: help, one or more arguments are not strings. |
| 327 |
\end{semiverbatim} |
| 328 |
} |
| 329 |
\end{frame} |
| 330 |
|
| 331 |
% page 18 |
| 332 |
\begin{frame}{Conclusions} |
| 333 |
\begin{itemize} |
| 334 |
\item Two ways to check for modulefile syntax errors. |
| 335 |
\item One for building modulefiles |
| 336 |
\item Another for checking site module tree. |
| 337 |
\end{itemize} |
| 338 |
\end{frame} |
| 339 |
|
| 340 |
% page 19 |
| 341 |
\begin{frame}{Future Topics} |
| 342 |
\begin{itemize} |
| 343 |
\item Unknown at the moment. |
| 344 |
\item Next Meeting will be March 7th at 9:30 Central (15:30 UTC) |
| 345 |
\end{itemize} |
| 346 |
\end{frame} |
| 347 |
|
| 348 |
\end{document} |