pyslurm icon indicating copy to clipboard operation
pyslurm copied to clipboard

Unclear that `Jobs.load()` returns a dictionary.

Open multimeric opened this issue 1 year ago • 2 comments

I'm testing out the new API. It seems that Jobs.load() returns a dict[int, Job] whose keys are the job IDs. However this isn't explained in the docs. This is a change from the previous API which returned some kind of list-type iterable (I forget what).

multimeric avatar May 29 '23 07:05 multimeric

Hi,

the Jobs class basically inherits from dict, and Jobs.load() returns a new instance of a Jobs collection that contains all the jobs in the system at the moment of calling. The documentation only says that the Jobs class inherits from dict (Bases: dict at the top) and contains Job objects, so I agree that it might not be entirely clear that the keys of this dict are the job ids.

I will try to make it more clear in the docs that the Jobs collection inherits from dict and basically has the form of dict[int, Job], where the keys are the job-ids. Would that be good?

tazend avatar May 29 '23 08:05 tazend

Okay that's a fair point, there is technically the right information there already. I think it's hindered by the fact that my IDE has no idea what fields these classes have. But the information you mention would be a good addition.

multimeric avatar May 29 '23 08:05 multimeric