Closed Overlytic closed 2 months ago
Hi,
the reason it works with the dictionary, is because you actually populate the dictionary with the previous job_data that was loaded.
When creating and initializing a pyslurm.Jobs
object with, for example, just a list of job-ids, like this:
jobs = pyslurm.Jobs(jobs=my_list_of_job_ids)
it will just create initially empty pyslurm.Job
objects inside the pyslurm.Jobs
collection. Basically, creating a pyslurm.Jobs
object does not do anything with the slurm API. To really (re)load the data of the Jobs you just initialized the collection with, you need to call the reload()
method - which can be called over and over to update the job data in a existing collection. So, when initializing with a list of job-ids, you need to do this in order to actually fetch the data:
jobs = pyslurm.Jobs(jobs=my_list_of_job_ids).reload()
reload()
just returns self
, so it can be chained conveniently.
I didn't want to have the jobs be loaded implicitly when creating a pyslurm.Jobs
collection, so it needs to be explicitly done with the reload()
method. (because sometimes, you might just want to sort out existing pyslurm.Job
objects into a different pyslurm.Jobs
collection, like seperating running and pending jobs for example.)
Aah that makes sense! Thanks for clarifying!
Details
Issue
The Jobs.cpus variable is not updating when loading jobs using a list of job ids. Instead of summing all cpus, it only loads the number of jobs. It works correctly when loading using a dictionary though.