Skip to content

JobBundling.get_all_job_ids() doesn't return a list of ids! #24

@Tony-Makdissy

Description

@Tony-Makdissy

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:

  1. Add __repr__ method to SlurmJobReference class that should be the id. However, I think this solution isn't the best because the representation should represent more information about the class.
  2. Edit flush method in JobBundling class by applying get_job_id on all items of job_ids before extending _all_job_ids. i.e. add job_ids = map(lambda x: x.get_job_id(), job_ids) just after the for loop.
  3. Make the function get_dispatcher calls SlurmDispatcher or DirectCallDispatcher and 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions