@@ -272,6 +272,20 @@ cdef class Statistics:
272
272
273
273
@staticmethod
274
274
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
+ """
275
289
cdef:
276
290
stats_info_request_msg_t req
277
291
stats_info_response_msg_t * resp = NULL
@@ -291,11 +305,30 @@ cdef class Statistics:
291
305
292
306
@staticmethod
293
307
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
+ """
294
317
cdef stats_info_request_msg_t req
295
318
req.command_id = slurm.STAT_COMMAND_RESET
296
319
verify_rpc(slurm_reset_statistics(& req))
297
320
298
321
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
+ """
299
332
out = instance_to_dict(self )
300
333
out[" rpcs_by_type" ] = xcollections.dict_recursive(self .rpcs_by_type)
301
334
out[" rpcs_by_user" ] = xcollections.dict_recursive(self .rpcs_by_user)
@@ -305,6 +338,26 @@ cdef class Statistics:
305
338
return out
306
339
307
340
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
+
308
361
cdef parse_response(stats_info_response_msg_t * ptr):
309
362
cdef Statistics out = Statistics()
310
363
0 commit comments