Repository navigation
Use SpecCluster name in worker names - #3855
Conversation
|
Slightly tangential: something I would love to get input on as well is what to do with the spec I have read the SpecCluster docstring and this certainly looks like something that applies here (a single entry in the spec creates multiple Dask workers). Looking at the code it feels the spec Note that in Dask-Jobqueue there would be two reasons of multiple Dask workers here:
|
| worker_name_template = f"{self._name}-{{}}" | ||
| worker_name = worker_name_template.format(self._i) |
There was a problem hiding this comment.
What if instead we generalize this to having a SpecCluster._new_worker_name method or something similar? Today this would be the following by default
def _new_worker_name(self):
while self._i in self.worker_spec:
self._i += 1
return self._iBut Dask-JobQueue could overwrite it on its own method.
This is just one idea, but shows how we might generailize something on SpecCluster that would make it easier to modify downstream without changing default behaviors on SpecCluster itself.
There was a problem hiding this comment.
This seems completely reasonable (I thought about adding a worker_name_func as an argument to SpecCluster.__init__ which seems slightly overcomplicated but not the good old object-oriented approach), I'll do this and add some tests as well.
There was a problem hiding this comment.
I added the _new_worker_name(self, worker_number) method. Taking the worker_number as argument of _new_worker_name seems like it will be simpler to customise in Dask-Jobqueue (no need for the self._i updating logic).
I also added some simple tests.
I am making the PR ready for review now that there are tests.
|
This looks good to me. There was an unrelated test failure (I think). I'm going to increase a timeout and see if that helps (I hope that you do not mind my pushing to your branch). |
I actually think this is a super useful feature and allow more productive iterations (both from the contributor and the maintainer point of view), so clearly pushes to my branches more than welcome! |
So this comes from a long discussion about using job arrays in Dask-Jobqueue iin dask/dask-jobqueue#196.
I'll try to summarise it:
the problem is that this script will be run 3 times (the size of the job array) and workers will have the same name causing an error
so that the job submission script would look like this:
This PR is an attempt at doing this. Suggestions on how to improve it would be more than welcome!
This modification is only motivated by Dask-Jobqueue so it could be argued that it should stay in Dask-Jobqueue. My feeling is that:
__repr__)new_worker_specin Dask-Jobqueue to do what we want. The latter approach feels more fragile and could break if some of the SpecCluster internals changed.If I am being honest the Dask-Jobqueue use case feels a little bit kludgy because the key of the spec would be
wathever_$SGE_TASK_ID-0,wathever_$SGE_TASK_ID-1and the worker names would bewhatever_1-0,whatever_2-0,whatever_3-0,whatever_1-1, etc ... not sure it that could cause a problem later down the line.