Description
Hi,
right now I believe the codebase is a bit unpleasant to maintain and add new stuff to, since everything is put into one big file that consists of thousands of lines. From my perspective, in order to have a cleaner interface, it would probably be best to put some effort into splitting up that big file into seperate modules where possible. Seperation of concerns (e.g slurmdbd stuff is mostly completely unrelated to other things like partition info).
Also the way classes are used right now is probably not the best way. The classes don't really have a purpose and merely act as a namespace for related functions, returning the information in dictionaries instead of utilizing instance attributes.
For example, all the functions from the partition class could be put into a seperate partition.pyx module, and the user can then do calls like partition.get()
, partition.create()
...and so on, no classes needed in that case, especially when everything is done via dictionaries.
However, it could also be benefitial to turn the current "classes" into actual classes, by defining instance attributes and going away from the approach with handing out dictionaries, letting the instances itself hold all the relevant information , e.g for Partition:
class Partition:
def __init__(self, name, **kwargs):
self.name = name
self.nodes = ...
self.allow_accounts = ...
self.qos = ...
...and so on...
def create(self)
...
Then one can actually do stuff like:
p = Partition("debug", options)
p.create()
It would probably be the best to improve the classes like this, and the code would be much more maintainable when also split into different files. Also, there is plenty of code that could need an update, not all things are safe and guaranteed to work when pushing a new major version. Besides that, doing from .pyslurm import *
is also pretty evil in such a big file 😂
I would definitely if desired and whenever I have the time, put some effort into the things described above (and already doing so for the Partition case described above). Though it would for sure take a while for everything, but it could be upgraded gradually. Now of course doing things like this might be API breaking, but the current pyslurm.pyx file doesn't have to be touched though when simply branching out into seperate modules.
These are just some thoughts I had on the current code.