Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Stop workers politely #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

pitrou
Copy link
Member

@pitrou pitrou commented May 31, 2017

No description provided.

@pitrou
Copy link
Member Author

pitrou commented May 31, 2017

@mrocklin

JOB_IDS = ['JOB_ID', 'SLURM_JOB_ID', 'LSB_JOBID']
JOB_ID = ''.join('$' + s for s in JOB_IDS)
TASK_IDS = ['SGE_TASK_ID', 'SLURM_ARRAY_TASK_ID', 'LSB_JOBINDEX']
TASK_ID = ''.join('$' + s for s in TASK_IDS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems much cleaner

logger.info("Starting workers due to resource constraints: %s", workers)

if busy and not s.idle:
workers = self.cluster.start_workers(len(busy))
workers = yield self.cluster._start_workers(len(busy))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, thank you for catching this.

raise gen.Return(workers)

@gen.coroutine
def _wait_for_started_workers(self, ids, timeout, kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases we may ask for many more workers than we are likely to get from the job scheduler. Thoughts on how to make this process robust to getting only some of the requested workers? Perhaps a coroutine per worker?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the job scheduler may refuse to launch certain jobs? I don't really know how job schedulers work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, actually, I suppose that since we're doing array jobs the job scheduler will probably allocate workers in an all-or-nothing manner. I'll retract my comment. In the future we may want to change start_workers to ask for batches of workers in some ideal size.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thought I'd chime in: with array jobs you can actually get scheduled incrementally, and it would be nice for jobs to start working without waiting for the other workers.

@pitrou pitrou closed this May 31, 2017
@pitrou pitrou reopened this May 31, 2017
@pitrou
Copy link
Member Author

pitrou commented May 31, 2017

Closed & re-opened to try and schedule a Travis build.


# We got enough new workers, see if they correspond
# to the runBulkJobs request
environs = yield client._run(get_environ, workers=worker_addresses)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, we may be able to exploit the fact that we pass the job id as --name to dask-worker?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original intent with passing --name. I wasn't able to get this to work robustly though. In the end I think I decided to just rely on the scheduler to close things down politely and avoid having to maintain a map between worker addresses and sge job ids.

Copy link
Member Author

@pitrou pitrou Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you found what was the cause of the flakiness? It seems that --name itself should be decently robust, and I would be surprised if the environment variables weren't always present -- besides, those are the same environment variables my code uses, so it would have the same problem.

@mrocklin
Copy link
Member

mrocklin commented Jun 1, 2017 via email

@pitrou
Copy link
Member Author

pitrou commented Jun 1, 2017

I wasn't able to get the job scheduler to reliably use the environment variables.

You mean set them? Or are they set manually by the system administrator?

@mrocklin
Copy link
Member

mrocklin commented Jun 1, 2017

The environment variables are, I think, set by the job scheduler when creating the job. So our current approach is to do something like the following:

dask-worker ... --name $JOB_ID:TASK_ID

And we expect this to create a name like 16.1. However I found that this wasn't the case. Perhaps things have improved since then though. Regardless, my hope was to just avoid needing to need this mapping altogether. Is needing this mapping proving to be important now?

@pitrou
Copy link
Member Author

pitrou commented Jun 1, 2017

Is needing this mapping proving to be important now?

Well, if we want to "politely" stop workers, then yes it is :-) At least, the environment variables need to be set properly.

@mrocklin
Copy link
Member

mrocklin commented Jun 1, 2017

This is only if we want to politely stop workers with certain Job IDs though, yes? Is this an important feature?

@pitrou
Copy link
Member Author

pitrou commented Jun 1, 2017

This is only if we want to politely stop workers with certain Job IDs though, yes?

Oh, I hadn't thought about that. Yes, that's a good point.

Is this an important feature?

I don't know. But it had a xfail test case :-)

@jakirkham
Copy link
Member

Any thoughts on the merge conflicts?

@pitrou
Copy link
Member Author

pitrou commented Nov 3, 2017

@jakirkham that depends if this PR is desirable at all. I see @TomAugspurger did some changes on dask-drmaa semi-recently, perhaps he has an opinion on this.

@TomAugspurger
Copy link
Member

No strong thoughts. Glancing through the changes, this approach seems better than the changes in af9273f (which was only focused on making sure that the temporary worker directories are cleaned up).

@pitrou
Copy link
Member Author

pitrou commented Nov 3, 2017

@jakirkham perhaps you would be interested in trying to rebase this PR / fix the conflicts?

@jakirkham
Copy link
Member

Not right now. Maybe later. Mainly interested in getting this released and then making use of it. Afterwards we can revisit outstanding issues.

@mrocklin
Copy link
Member

mrocklin commented Nov 3, 2017 via email

@jakirkham
Copy link
Member

That is very interesting. Thanks for the link.

We do have a strategy in place for starting jobs on the cluster. For legacy reasons, it uses ipyparallel and then launches a distributed cluster on top of that. Though am now thinking that maybe we should just use distributed directly. Switching to this drmaa-based startup method looks to be a small change, which will do the job. So think we'll try that near term to address our needs. If this needs to change again for some reason, will revisit other options down the road.

@mrocklin
Copy link
Member

mrocklin commented Nov 3, 2017

DRMAA seems simple enough that if it fits it's a good choice. I certainly know of groups that use this package daily. They're able to hand it to new developers who seem to find it comfortable enough. I think that challenges have arisen whenever groups have wanted to do clever things with their job scheduler and the DRMAA interface wasn't sufficiently expressible. In that case sometimes providing a custom job script to dask-drmaa worked nicely. In other cases it was too complex.

@jakirkham
Copy link
Member

Yeah have used DRMAA in the past for other applications and have found it works quite well for simple tasks. Have pretty minimal requirements as to what the Distributed cluster needs to do. So think this should be ok. Especially after some brief experimentation with it.

This may be just my opinion; however, in cases of more complex usage, it's probably not just DRMAA that is insufficiently expressive, but the underlying scheduler as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants