pbs_python.1B 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. .\" Copyright (C) 1994-2018 Altair Engineering, Inc.
  2. .\" For more information, contact Altair at www.altair.com.
  3. .\"
  4. .\" This file is part of the PBS Professional ("PBS Pro") software.
  5. .\"
  6. .\" Open Source License Information:
  7. .\"
  8. .\" PBS Pro is free software. You can redistribute it and/or modify it under the
  9. .\" terms of the GNU Affero General Public License as published by the Free
  10. .\" Software Foundation, either version 3 of the License, or (at your option) any
  11. .\" later version.
  12. .\"
  13. .\" PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
  14. .\" WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. .\" FOR A PARTICULAR PURPOSE.
  16. .\" See the GNU Affero General Public License for more details.
  17. .\"
  18. .\" You should have received a copy of the GNU Affero General Public License
  19. .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. .\"
  21. .\" Commercial License Information:
  22. .\"
  23. .\" For a copy of the commercial license terms and conditions,
  24. .\" go to: (http://www.pbspro.com/UserArea/agreement.html)
  25. .\" or contact the Altair Legal Department.
  26. .\"
  27. .\" Altair’s dual-license business model allows companies, individuals, and
  28. .\" organizations to create proprietary derivative works of PBS Pro and
  29. .\" distribute them - whether embedded or bundled with other software -
  30. .\" under a commercial license agreement.
  31. .\"
  32. .\" Use of Altair’s trademarks, including but not limited to "PBS™",
  33. .\" "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
  34. .\" trademark licensing policies.
  35. .\"
  36. .TH pbs_python 1B "23 October 2017" Local "PBS Professional"
  37. .SH NAME
  38. .B pbs_python
  39. \- Python interpreter for debugging a hook script from the command line
  40. .SH SYNOPSIS
  41. .B pbs_python
  42. --hook [-e <log event mask>] [-i <event input file>]
  43. .RS 11
  44. [-L <log dir>] [-l <log file>] [-o <hook execution record>]
  45. .br
  46. [-r <resourcedef file>] [-s <site data file>] [<Python script>]
  47. .RE
  48. .B pbs_python
  49. <standard Python options>
  50. .B pbs_python
  51. --version
  52. .SH DESCRIPTION
  53. The PBS Python interpreter,
  54. .B pbs_python,
  55. is a wrapper for Python.
  56. You can use the
  57. .B pbs_python
  58. wrapper that is shipped with PBS to debug hooks. Either:
  59. .RS 5
  60. Use the
  61. .I --hook
  62. option to
  63. .B pbs_python
  64. to run
  65. .B pbs_python
  66. as a wrapper to Python, employing the
  67. .B pbs_python
  68. options. With the
  69. .I --hook
  70. option, you cannot use the standard Python options. The rest of this
  71. man page covers how to use
  72. .B pbs_python
  73. with the
  74. .I --hook
  75. option.
  76. Do not use the
  77. .I --hook
  78. option, so
  79. .B pbs_python
  80. runs the Python interpreter, with the standard Python options, and without access to
  81. the
  82. .B pbs_python
  83. options.
  84. .RE
  85. .B Debugging Hooks
  86. .br
  87. You can get each hook to write out debugging files, and then modify the files
  88. and use them as debugging input to
  89. .B pbs_python.
  90. Alternatively, you can write them yourself.
  91. Debugging files can contain information about the event, about the site, and
  92. about what the hook changed. You can use these as inputs to a hook when debugging.
  93. For a complete description of using
  94. .B pbs_python
  95. with debugging files, see "Debugging Hooks" in the PBS Professional Hooks Guide.
  96. .SH Options to pbs_python
  97. .IP "--hook" 6
  98. This option is a switch. When you use this option, you can use the
  99. PBS Python module (via "import pbs"), and the other options described
  100. here are available. When you use this option, you cannot use the
  101. standard Python options. This option is useful for debugging.
  102. When you do not use this option, you cannot use
  103. the other options listed here, but you can use the standard
  104. Python options.
  105. .IP "-e <log event mask>" 6
  106. Sets the mask that determines which event types are logged by
  107. .B pbs_python.
  108. To see only debug messages, set the value to 0xd80. To
  109. see all messages, set the value to 0xffff.
  110. .br
  111. The
  112. .B pbs_python
  113. interpreter uses the same set of mask values that are
  114. used for the
  115. .I $logevent <mask>
  116. entry in the
  117. .B pbs_mom
  118. configuration file.
  119. See the pbs_mom.8B man page. Available only when
  120. .I --hook
  121. option is used.
  122. .IP "-i <event input file>" 6
  123. Text file containing data to populate pbs.event() objects.
  124. Each line specifies an attribute value or a resource value. Syntax of
  125. each input line is one of the following:
  126. .RS 10
  127. <object name>.<attribute name>=<attribute value>
  128. .br
  129. <object name>.<resource list>[<resource name>]=<resource value>
  130. .RE
  131. .IP
  132. Where
  133. .RS 10
  134. <object name> is a PBS object name which can refer to its sub-objects. Examples:
  135. "pbs.event()", "pbs.event().job", "pbs.event().vnode_list["<vnode name>"]".
  136. .RE
  137. .IP
  138. Example input file:
  139. .RS 10
  140. .br
  141. pbs.event().hook_name=proto
  142. .br
  143. pbs.event().hook_type=site
  144. .br
  145. pbs.event().type=queuejob
  146. .br
  147. pbs.event().requestor=user1
  148. .br
  149. pbs.event().requestor_host=host1
  150. .br
  151. pbs.event().hook_alarm=40
  152. .br
  153. pbs.event().job.id=72
  154. .br
  155. pbs.event().job.Job_Name=job1
  156. .br
  157. pbs.event().job.Resource_List[ncpus]=5
  158. .br
  159. pbs.event().job.Resource_List[mem]=6mb
  160. .br
  161. pbs.event().vnode_list["host1"].resources_available["ncpus"] = 5
  162. .br
  163. pbs.event().vnode_list["host1"].resources_available["mem"] = 300gb
  164. .RE
  165. .IP
  166. Available only when
  167. .I --hook
  168. option is used.
  169. .IP "-L <log dir>" 6
  170. Directory holding the log file where pbs.logmsg() and pbs.logjobmsg()
  171. write their output. Default is current working directory where
  172. .B pbs_python
  173. is executed.
  174. Available only when
  175. .I --hook
  176. option is used.
  177. .IP "-l <log file>" 6
  178. Log file where pbs.logmsg() and pbs.logjobmsg() write their output.
  179. Default file name is current date in
  180. .I yyyymmdd
  181. format.
  182. Available only when
  183. .I --hook
  184. option is used.
  185. .IP "-o <hook execution record>" 6
  186. The hook execution record contains the changes made after executing the hook
  187. script, such as the attributes and resources set in any pbs.event()
  188. jobs and reservations, whether an action was accepted or rejected, and any
  189. pbs.reject() messages.
  190. .br
  191. Example hook execution record:
  192. .RS 10
  193. .br
  194. pbs.event().job.Job_Name=job2
  195. .br
  196. pbs.event().job.Resource_List[file]=60gb
  197. .br
  198. pbs.event().job.Resource_List[ncpus]=5
  199. .br
  200. pbs.event().job.Resource_List[mem]=20gb
  201. .br
  202. pbs.event().job.Account_Name=account2
  203. .br
  204. pbs.event().reject=True
  205. .br
  206. pbs.event().reject_msg=No way!
  207. .RE
  208. .IP
  209. Without this option, output goes to stdout.
  210. .IP
  211. Available only when
  212. .I --hook
  213. option is used.
  214. .IP "-r <resourcedef file>" 6
  215. File/path name containing a resource definition specifying a custom
  216. resource whose Python type is
  217. .I pbs.resource.
  218. .br
  219. Format:
  220. .br
  221. .I <resource name> type=<typename> [flag=<value>]
  222. .br
  223. This file has the same format as the PBS_HOME/server_priv/resourcedef
  224. file. Available only when
  225. .I --hook
  226. option is used.
  227. .IP "-s <site data file>" 6
  228. The site data file can contain any relevant information about the
  229. server, queues, vnodes, and jobs at the server. This file
  230. can be written by a hook or by the administrator.
  231. .br
  232. When the hook writes it, this file contains the values that populate
  233. the server, queues, vnodes, reservations, and jobs, with all
  234. attributes and resources for which there are values.
  235. .br
  236. The site data file is named
  237. .I hook_<event type>_<hook name>_<random integer>.data.
  238. Available only when
  239. .I --hook
  240. option is used.
  241. .IP "--version" 6
  242. The
  243. .B pbs_python
  244. command prints its version information and exits. This option
  245. can only be used alone.
  246. .SH ARGUMENTS
  247. .IP "<Python script>" 6
  248. The hook script to execute.
  249. We recommend importing the PBS Python module at the start of the script:
  250. .RS 9
  251. import pbs
  252. .RE
  253. .IP
  254. If you do not specify
  255. .I Python script,
  256. you can perform interactive
  257. debugging. If you type the following:
  258. .RS 9
  259. pbs_python --hook -i hook.input
  260. .RE
  261. .IP
  262. The interpreter displays a prompt:
  263. .RS 9
  264. >>
  265. .RE
  266. .IP
  267. You can type your Python lines at the prompt:
  268. .RS 9
  269. >>import pbs
  270. .br
  271. >> e=pbs.event().job
  272. .br
  273. >> print e.id
  274. .br
  275. <job ID>
  276. .br
  277. ...
  278. .RE