-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[autoscaler] Fix confirmation (y/N) for autoscaler for Python 2 #1450
Conversation
Merged build finished. Test PASSed. |
Test PASSed. |
python/ray/autoscaler/commands.py
Outdated
@@ -171,7 +171,10 @@ def get_or_create_head_node(config, no_restart): | |||
|
|||
def confirm(msg): | |||
print("{}. Do you want to continue [y/N]? ".format(msg), end="") | |||
answer = input() | |||
if sys.version_info[0] > 2: |
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.
it would be more consistent with the rest of the codebase to do
if sys.version_info >= (3, 0):
Merged build finished. Test PASSed. |
Test PASSed. |
python/ray/autoscaler/commands.py
Outdated
if sys.version_info >= (3, 0): | ||
answer = input() | ||
else: | ||
answer = raw_input() # noqa: F821 |
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.
two spaces before comments.. this will probably be another linting error
Merged build finished. Test PASSed. |
Test PASSed. |
Merged build finished. Test PASSed. |
Test PASSed. |
What do these changes do?
This is a small fix to make the confirmation question work as expected in Python 2. There is a small inconsistency between Python 2 and Python 3 input (namely in Python 2 the result is evaled), which gives a "no such variable y" error in Python 2.
Without this fix, the user has to type 'y' instead of y to make sure the result of eval is a string.