-
Notifications
You must be signed in to change notification settings - Fork 4
JobBundling.get_all_job_ids() doesn't return a list of ids! #24
Description
JobBundling.get_all_job_ids() doesn't return a list of ids! It returns a list of slurminade.dispatcher.SlurmJobReference instead. However, iterating over the list of SlrumJobRefrence and applying get_job_id will do the trick!
example:
## Assuming I have a JobBundling object called bundle
print("1st output",bundle.get_all_job_ids())
wanted_output = list(
map(lambda x: x.get_job_id(), bundle.get_all_job_ids())
)
print("2nd output",wanted_output)The output will look like this:
1st output [<slurminade.dispatcher.SlurmJobReference object at 0x7fb258638470>, <slurminade.dispatcher.SlurmJobReference object at 0x7fb257f68a40>]
2nd output [40911167, 40911168]
I have three suggested fixes. but I'm not that good in OOP so I'm not super sure what is the best way to fix it!
From the one I like the least to the most:
- Add
__repr__method toSlurmJobReferenceclass that should be theid. However, I think this solution isn't the best because the representation should represent more information about the class. - Edit
flushmethod inJobBundlingclass by applyingget_job_idon all items ofjob_idsbefore extending_all_job_ids. i.e. addjob_ids = map(lambda x: x.get_job_id(), job_ids)just after the for loop. - Make the function
get_dispatchercallsSlurmDispatcherorDirectCallDispatcherand then return the id instead of the chosen class, but then you have to define a "Direct_id"! I'm still learning how to use your library so I don't know if a "Direct_id" makes any sense!
Since I don't know the full scope of your code I didn't try to implement any of the changes (sorry for being lazy!) but I hope these suggestions might help.
As a side suggestion, I think __repr__ method should replace the get_info method for all the JobRefrence classes (LocalJobReference, TestJobReference, SubprocessJobReference, and SlurmJobReference). Or use both, to still be able to access the needed information as a dictionary.
In the end, let me thank you for this amazing library, I think it will save me a lot of hassle that I've been trying to solve for more than a year now.