Skip to content

Commit b42fc12

Browse files
committed
finalize documentation
1 parent 256337b commit b42fc12

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

pyslurm/core/slurmctld/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
)
77
from .enums import ShutdownMode
88
from .stats import (
9+
diag,
910
Statistics,
1011
ScheduleExitStatistics,
1112
BackfillExitStatistics,

pyslurm/core/slurmctld/stats.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ cdef class RPCUser:
207207

208208

209209
cdef class RPCTypeStatistics(dict):
210-
"""Collection of [](pyslurm.slurmctld.RPCTypeStatistic)'s
210+
"""Collection of [pyslurm.slurmctld.RPCType][] objects.
211211
212212
Attributes:
213213
count (int):
@@ -224,7 +224,7 @@ cdef class RPCTypeStatistics(dict):
224224

225225

226226
cdef class RPCUserStatistics(dict):
227-
"""Collection of [](pyslurm.slurmctld.RPCUser)'s
227+
"""Collection of [pyslurm.slurmctld.RPCUser][] objects.
228228
229229
Attributes:
230230
count (int):
@@ -237,7 +237,7 @@ cdef class RPCUserStatistics(dict):
237237

238238

239239
cdef class RPCPendingStatistics(dict):
240-
"""Collection of [](pyslurm.slurmctld.RPCPendingStatistics)
240+
"""Collection of [pyslurm.slurmctld.RPCPending][] objects.
241241
242242
Attributes:
243243
count (int):

pyslurm/core/slurmctld/stats.pyx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,20 @@ cdef class Statistics:
272272

273273
@staticmethod
274274
def load():
275+
"""Load the Statistics of the `slurmctld`.
276+
277+
Returns:
278+
(pyslurm.slurmctld.Statistics): The Controller statistics.
279+
280+
Raises:
281+
(pyslurm.RPCError): When fetching the Statistics failed.
282+
283+
Examples:
284+
>>> from pyslurm import slurmctld
285+
>>> stats = slurmctld.Statistics.load()
286+
>>> print(stats.jobs_completed, stats.schedule_cycle_counter)
287+
10 20
288+
"""
275289
cdef:
276290
stats_info_request_msg_t req
277291
stats_info_response_msg_t *resp = NULL
@@ -291,11 +305,30 @@ cdef class Statistics:
291305

292306
@staticmethod
293307
def reset():
308+
"""Reset the Statistics of the `slurmctld`.
309+
310+
Raises:
311+
(pyslurm.RPCError): When resetting the Statistics failed.
312+
313+
Examples:
314+
>>> from pyslurm import slurmctld
315+
>>> slurmctld.Statistics.reset()
316+
"""
294317
cdef stats_info_request_msg_t req
295318
req.command_id = slurm.STAT_COMMAND_RESET
296319
verify_rpc(slurm_reset_statistics(&req))
297320

298321
def to_dict(self):
322+
"""Convert the statistics to a dictionary.
323+
324+
Returns:
325+
(dict): Statistics as a dict.
326+
327+
Examples:
328+
>>> from pyslurm import slurmctld
329+
>>> stats = slurmctld.Statistics.load()
330+
>>> stats_dict = stats.to_dict()
331+
"""
299332
out = instance_to_dict(self)
300333
out["rpcs_by_type"] = xcollections.dict_recursive(self.rpcs_by_type)
301334
out["rpcs_by_user"] = xcollections.dict_recursive(self.rpcs_by_user)
@@ -305,6 +338,26 @@ cdef class Statistics:
305338
return out
306339

307340

341+
def diag():
342+
"""Load the Statistics of the `slurmctld`.
343+
344+
This is a shortcut for [pyslurm.slurmctld.Statistics.load][]
345+
346+
Returns:
347+
(pyslurm.slurmctld.Statistics): The Controller statistics.
348+
349+
Raises:
350+
(pyslurm.RPCError): When fetching the Statistics failed.
351+
352+
Examples:
353+
>>> from pyslurm import slurmctld
354+
>>> stats = slurmctld.Statistics.load()
355+
>>> print(stats.jobs_completed, stats.schedule_cycle_counter)
356+
10 20
357+
"""
358+
return Statistics.load()
359+
360+
308361
cdef parse_response(stats_info_response_msg_t *ptr):
309362
cdef Statistics out = Statistics()
310363

0 commit comments

Comments
 (0)