PySlurm/pyslurm

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

multimeric opened this issue · 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).

tazend commented

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?

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.