forked from pwrapi/powerapi_spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LangPythonCommon.tex
273 lines (268 loc) · 13.3 KB
/
LangPythonCommon.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
\section{High Level (Common) Methods}\label{sec:PythonHighLevelCommonMethods}
\subsection{Report Methods}\label{sec:PythonReportMethods}
%==============================================================================%
\subsubsection{Method pwr.Cntxt.GetReportByID} \label{meth:GetReportByID}
Please see the C API specification (section \ref{func:GetReportByID} on page
\pageref{func:GetReportByID}) for a verbose description of the \texttt{GetReportByID()} method. Also, please see
\ref{class:ID} on page \pageref{class:ID} and/or vendor implementation specific
documentation for valid IDs. To collect statistics for an \texttt{idStr} and \texttt{idType} combination, the \texttt{GetReportByID()} method may be used.
\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
statValue, timePeriod = myPwrCntxt.GetReportByID(idStr, idType, attrName,
pwrAttrStat, pwrTimePeriod)
#
# Where:
# idstr is a string ID for the report to be generated.
# idType is a pwr.ID type used to interpret the idstr ID
# attrName is a pwr.AttrName type
# pwrAttrStat is a pwr.AttrStat object
# pwrTimePeriod is a pwr.TimePeriod object
# Returns:
# statValue is the requested statistic
# timePeriod is the pwr.TimePeriod of the statistic
# This method raises a pwr.PwrError exception when something goes wrong.
# The possible exception errors are:
# pwr.ReturnCode.FAILURE
# pwr.ReturnCode.NOT_IMPLEMENTED
#
\end{lstlisting}\end{minipage}\end{center}
%\subsubsection{Method pwr.Cntxt.GetJobInfo} \label{meth:GetJobInfo}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%This method retrieves attributes, nodes, and timing(s) for a given job and/or run ID. The arguments \texttt{jobID} and \texttt{runID} are keyword arguments, and at least one of \texttt{jobID} or \texttt{runID} must be defined.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%jobAttr, phys2Nid, jobGrp, jobTP = myPwrCntxt.GetJobInfo(jobID=None, runID=None)
%#
%# Where:
%# jobID is a string ID for the job (i.e., job ID)
%# runID is an integer run ID.
%# Returns:
%# jobAttr is a named tuple of job attributes (job ID, run ID(s), and
%# user ID)
%# physical2NidMap is a dictionary that maps physical component names in
%# the job to Node IDs (nids)
%# jobNodesGrp is a group of comprised of the pwr.ObjType.NODE objects for the
%# job
%# timePeriod is a list of pwr.TimePeriod objects for the job. In the case of
%# a suspended/resumed job, the list has length greater than one.
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.EMPTY
%# pwr.ReturnCode.BAD_VALUE
%#
%\end{lstlisting}\end{minipage}\end{center}
%
%\subsubsection{Method pwr.Cntxt.GetJobsByUser} \label{meth:GetJobsByUser}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%This method of the \texttt{pwr.Cntxt} class gets a list of (job ID, run ID) tuples for a given userId (uid) and time period.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%jobList = myPwrCntxt.GetJobsByUser(userId, pwrTimePeriod=None)
%#
%# Where:
%# userId is a user ID (integer uid)
%# pwrTimePeriod is a pwr.TimePeriod object to scope the query. If not supplied,
%# the entire job history is searched.
%# Returns:
%# A list of (job ID, apid) tuples matching the user ID userId and the time
%# period pwrTimePeriod (if supplied).
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.BAD_VALUE
%#
%\end{lstlisting}\end{minipage}\end{center}
%
%\subsubsection{Method pwr.Cntxt.GetJobsByTime} \label{meth:GetJobsByTime}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%This method of the \texttt{pwr.Cntxt} class gets a list of (job ID, runID) tuples for a given (optional) time period.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%jobList = myPwrCntxt.GetJobsByTime(pwrTimePeriod=None)
%#
%# Where:
%# pwrTimePeriod is a pwr.TimePeriod object to scope the query. If not supplied,
%# the entire job history is searched.
%# Returns:
%# A list of (job ID, apid) tuples matching the time period pwrTimePeriod
%# (if supplied).
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%#
%\end{lstlisting}\end{minipage}\end{center}
%
%\subsubsection{Method pwr.Obj.WriteTimeSeriesCSV} \label{meth:objWriteTimeSeriesCSV}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%This method of the \texttt{pwr.Obj} class writes a time series for an object to a file as comma-separated values (CSV). The column order of the CSV file is: timestamp, object name, attribute name, value.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%rc = myPwrObj.WriteTimeSeriesCSV(pwrAttr, pwrTimePeriod, filename)
%#
%# Where:
%# pwrAttr is a Power API attribute (e.g., pwr.AttrName.POWER,
%# pwr.AttrName.ENERGY)
%# pwrTimePeriod is a list of one or more non-overlapping pwr.TimePeriod
%# objects under which to generate a time series.
%# filename is the path and filename to which to write the comma-separated
%# values. A filename of `stdout' is treated as a special, using
%# sys.stdout to print to stdout.
%# Returns:
%# A return code, pwr.ReturnCode.SUCCESS for success.
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.BAD_VALUE
%#
%\end{lstlisting}\end{minipage}\end{center}
%
%
%\subsubsection{Method pwr.Grp.WriteTimeSeriesCSV} \label{meth:grpWriteTimeSeriesCSV}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%This method of the \texttt{pwr.Grp} class writes a time series for each object in a group to a file as comma-separated values (CSV). The column order of the CSV file is: timestamp, object name, attribute name, value.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%rc = myPwrGrp.WriteTimeSeriesCSV(pwrAttr, pwrTimePeriod, filename)
%#
%# Where:
%# pwrAttr is a Power API attribute (e.g., pwr.AttrName.POWER,
%# pwr.AttrName.ENERGY)
%# pwrTimePeriod is a list of one or more non-overlapping pwr.TimePeriod
%# objects under which to generate a time series.
%# filename is the path and filename to which to write the comma-separated
%# values. A filename of `stdout' is treated as a special, using
%# sys.stdout to print to stdout.
%# Returns:
%# A return code, pwr.ReturnCode.SUCCESS for success.
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.BAD_VALUE
%# pwr.ReturnCode.OP_NOT_ATTEMPTED
%#
%\end{lstlisting}\end{minipage}\end{center}
%
%\subsubsection{Method pwr.Grp.WriteAggregateTimeSeriesCSV} \label{meth:WriteAggregateTimeSeriesCSV}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%This method of the \texttt{pwr.Grp} class writes an aggregated time series for a group of objects to a file as comma-separated values (CSV). The column order of the CSV file is: timestamp, attribute name, value. This call is useful for getting a time series of a total over a group (e.g., total power over a group of nodes).
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%rc = myPwrGrp.WriteAggregateTimeSeriesCSV(pwrAttr, pwrTimePeriod, filename)
%#
%# Where:
%# pwrAttr is a Power API attribute (e.g., pwr.AttrName.POWER,
%# pwr.AttrName.ENERGY)
%# pwrTimePeriod is a list of one or more non-overlapping pwr.TimePeriod
%# objects under which to generate a time series.
%# filename is the path and filename to which to write the comma-separated
%# values. A filename of `stdout' is treated as a special, using
%# sys.stdout to print to stdout.
%# Returns:
%# A return code, pwr.ReturnCode.SUCCESS for success.
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.BAD_VALUE
%# pwr.ReturnCode.OP_NOT_ATTEMPTED
%#
%\end{lstlisting}\end{minipage}\end{center}
%
%%==============================================================================%
%\subsection{Convenience Methods}\label{sec:PythonConvenienceMethods}
%
%\subsubsection{Method pwr.Cntxt.GrpCreateByJobID} \label{meth:GrpCreateByJobID}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%Given a Job ID \texttt{jobIDStr}, this method of the \texttt{pwr.Cntxt} class returns a group of objects (of type \texttt{objType}) associated with the job.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%jobGroup = myPwrCntxt.GrpCreateByJobID(jobIDStr, objType)
%#
%# Where:
%# jobIDStr is a string ID for the job (i.e., job ID)
%# objType is a Power API object type (e.g., pwr.ObjType.NODE)
%#
%# Returns:
%# A group of objects of type objType associated with job ID jobIDStr.
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.BAD_VALUE
%#
%\end{lstlisting}\end{minipage}\end{center}
%
%\subsubsection{Method pwr.Cntxt.GrpCreateByRunID} \label{meth:GrpCreateByRunID}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%Given a Run ID \texttt{runID}, this method of the \texttt{pwr.Cntxt} class returns a group of objects (of type \texttt{objType}) associated with the run.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%runGroup = myPwrCntxt.GrpCreateByRunID(runID, objType)
%#
%# Where:
%# runID is an integer ID for the run (i.e., run ID)
%# objType is a Power API object type (e.g., pwr.ObjType.NODE)
%#
%# Returns:
%# A group of objects of type objType associated with run ID runID.
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.BAD_VALUE
%\end{lstlisting}\end{minipage}\end{center}
%
%\subsubsection{Method pwr.Cntxt.GrpCreateByName} \label{meth:GrpCreateByName}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%This method of the \texttt{pwr.Cntxt} class creates a group given a tuple of object/component physical names. If bad or non-existent names are given, they are silently ignored.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%physNameGroup = myPwrCntxt.GrpCreateByName(nameTuple, objType)
%#
%# Where:
%# nameTuple is a a tuple of string object/component physical names.
%# objType is a Power API object type (e.g., pwr.ObjType.NODE)
%#
%# Returns:
%# A group of objects derived from nameTuple.
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.BAD_VALUE
%\end{lstlisting}\end{minipage}\end{center}
%
%\subsubsection{Method pwr.Cntxt.GrpCreateByNidlist} \label{meth:GrpCreateByNidlist}
%\emph{NOTE: this method is proposed by Cray Inc. for inclusion into the specification. The text represents the APM4 implementation and may be altered pursuant to discussion/review}
%
%This method of the \texttt{pwr.Cntxt} class creates a group given a tuple of node IDs (nids). If bad or non-existent nids are given, they are silently ignored.
%
%\begin{center}\begin{minipage}{.95\linewidth}\begin{lstlisting}
%nidlistGroup = myPwrCntxt.GrpCreateByNidlist(nidTuple, objType)
%#
%# Where:
%# nidTuple is a a tuple of integer node IDs (nids).
%# objType is a Power API object type (e.g., pwr.ObjType.NODE)
%#
%# Returns:
%# A group of objects derived from nidTuple.
%# This method raises a pwr.PwrError exception when something goes wrong.
%# The possible exception errors are:
%# pwr.ReturnCode.FAILURE
%# pwr.ReturnCode.NOT_IMPLEMENTED
%# pwr.ReturnCode.BAD_VALUE
%\end{lstlisting}\end{minipage}\end{center}