-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Spot] Let cancel interrupt the spot job #1414
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c3a8599
Let cancel interrupt the job
Michaelvll 169e8b5
Add test
Michaelvll 3e8bac6
Fix test
Michaelvll e82d89c
Cancel early
Michaelvll c081c60
fix test
Michaelvll 3441b43
fix test
Michaelvll 88f4db5
Fix exceptions
Michaelvll 331fa32
pass test
Michaelvll 25c568c
increase waiting time
Michaelvll 71a253d
address comments
Michaelvll 5253d5d
add job id
Michaelvll 6e9ba0c
remove 'auto' in ray.init
Michaelvll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity - any particular reason to use Ray? Could this have been implemented with
multiprocessing
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, there is no particular reason for implementing it with
ray
. The only reason is that I am more familiar with the busy loop withray.wait
, and our VMs already have a ray cluster running in the background.Do you think it would be better to implement it with
multiprocessing
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think multiprocessing might be faster, but ray is also fine if its faster for us to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tried out
multiprocessing
,concurrent.futures
andasyncio
, and seems they all have the functionality to support running the process in parallel, but with drawbacks:multiprocessing.Process
: We can start the process and check the liveness of the process withis_alive
. We can cancel the process withos.kill(p.pid, signal.SIGINT)
. However, we cannot easily catch the exceptions happening inside the process from the main process. Additional codes are needed to do so, as mentioned here.concurrent.futures
: We can start the process with theExecutor.submit
and catch the exceptions from the main process, but the future object does not have a way to stop the running process, unlikeray.cancel
.asyncio.create_task
: Based on their doc, the task is not guaranteed to be cancelled, but we need that guarantee to cancel the_controller_run
function when theCANCEL
signal received.Based on the drawback above, I think it might be fine to use
ray
to handle the async and future as we did in the code. Wdyt @romilbhardwaj ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah for
multiprocessing
, I was thinking of usingmultiprocessing.Pool
since it provides nice exception handling, but turns out its not easy to cancel running processes in it.I think it's fine to use
ray
for now. Thanks for the extensive investigation into different methods to do this!