@@ -282,14 +282,19 @@ cdef class Jobs(dict):
282
282
return jobs
283
283
284
284
@staticmethod
285
- def modify (search_filter , db_connection = None , ** changes ):
285
+ def modify (search_filter , Job changes , db_connection = None ):
286
286
""" Modify Slurm database Jobs.
287
287
288
288
Implements the slurm_job_modify RPC.
289
289
290
290
Args:
291
291
search_filter (Union[pyslurm.db.JobSearchFilter, pyslurm.db.Jobs]):
292
292
A filter to decide which Jobs should be modified.
293
+ changes (pyslurm.db.Job):
294
+ Another [pyslurm.db.Job][] object that contains all the
295
+ changes to apply. Check the `Other Parameters` of the
296
+ [pyslurm.db.Job][] class to see which properties can be
297
+ modified.
293
298
db_connection (pyslurm.db.Connection):
294
299
A Connection to the slurmdbd. By default, if no connection is
295
300
supplied, one will automatically be created internally. This
@@ -306,25 +311,21 @@ cdef class Jobs(dict):
306
311
be committed or rolled back by using the respective methods on
307
312
the connection object. This way, you have a chance to see
308
313
which Jobs were modified before you commit the changes.
309
- **changes (Any):
310
- Check the `Other Parameters` Section of [pyslurm.db.Job][] to
311
- see what attributes can be modified.
312
314
313
315
Returns:
314
316
(list[int]): A list of Jobs that were modified
315
317
316
318
Raises:
317
- ValueError: When a parsing error occured or the Database
318
- connection is not open
319
319
RPCError: When a failure modifying the Jobs occurred.
320
320
321
321
Examples:
322
322
In its simplest form, you can do something like this:
323
323
324
324
>>> import pyslurm
325
+ >>>
325
326
>>> search_filter = pyslurm.db.JobSearchFilter(ids=[9999])
326
- >>> modified_jobs = pyslurm.db.Jobs.modify(
327
- ... search_filter, comment="A comment for the job" )
327
+ >>> changes = pyslurm.db.Job(comment="A comment for the job")
328
+ >>> modified_jobs = pyslurm.db.Jobs.modify( search_filter, changes )
328
329
>>> print(modified_jobs)
329
330
>>> [9999]
330
331
@@ -334,11 +335,13 @@ cdef class Jobs(dict):
334
335
connection object:
335
336
336
337
>>> import pyslurm
337
- >>> search_filter = pyslurm.db.JobSearchFilter(ids=[9999])
338
+ >>>
338
339
>>> db_conn = pyslurm.db.Connection.open()
340
+ >>> search_filter = pyslurm.db.JobSearchFilter(ids=[9999])
341
+ >>> changes = pyslurm.db.Job(comment="A comment for the job")
339
342
>>> modified_jobs = pyslurm.db.Jobs.modify(
340
- ... search_filter, db_conn,
341
- ... comment="A comment for the job")
343
+ ... search_filter, changes, db_conn)
344
+ >>>
342
345
>>> # Now you can first examine which Jobs have been modified
343
346
>>> print(modified_jobs)
344
347
>>> [9999]
@@ -348,7 +351,7 @@ cdef class Jobs(dict):
348
351
"""
349
352
350
353
cdef:
351
- Job job = Job( ** changes)
354
+ Job job = < Job> changes
352
355
JobSearchFilter jfilter
353
356
Connection conn = < Connection> db_connection
354
357
SlurmList response
@@ -499,23 +502,25 @@ cdef class Job:
499
502
500
503
return out
501
504
502
- def modify (self , db_connection = None , ** changes ):
505
+ def modify (self , changes , db_connection = None ):
503
506
""" Modify a Slurm database Job.
504
507
505
508
Args:
509
+ changes (pyslurm.db.Job):
510
+ Another [pyslurm.db.Job][] object that contains all the
511
+ changes to apply. Check the `Other Parameters` of the
512
+ [pyslurm.db.Job][] class to see which properties can be
513
+ modified.
506
514
db_connection (pyslurm.db.Connection):
507
515
A slurmdbd connection. See
508
516
[pyslurm.db.Jobs.modify][pyslurm.db.job.Jobs.modify] for more
509
- info
510
- **changes (Any):
511
- Check the `Other Parameters` Section of this class to see what
512
- attributes can be modified.
517
+ info on this parameter.
513
518
514
519
Raises:
515
520
RPCError: When modifying the Job failed.
516
521
"""
517
522
cdef JobSearchFilter jfilter = JobSearchFilter(ids = [self .id])
518
- Jobs.modify(jfilter, db_connection, ** changes )
523
+ Jobs.modify(jfilter, changes, db_connection )
519
524
520
525
@property
521
526
def account (self ):
0 commit comments