-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
[DO NOT MERGE] Rewrite YAPF scripts #1971
Conversation
Any options not set in the config file defer to pep8.
This runs faster thanks to the `--parallel` flag and YAPF's builtin features. It's also a little clearer (IMO), and was run through `shellcheck` to harden up against a few of bash's many gotchas. It also actually uses the .style.yapf in the project repo, which was previously ignored.
@ericl @richardliaw Are these linting changes ok with you? They look good to me! |
Personally, I'd tweak the |
Test FAILed. |
Regardless of the particular style used, we consider the updated script since it shaves about 30s off Travis builds. |
cd to parent of script, then use git to find its own root.
Test PASSed. |
Test PASSed. |
1. rm useless cd's 2. Unquote array since it turns out checking the truthiness of an array is a real pain in bash and is best done in Python or something. 3. rm useless `exit 0` since scripts exit with the status of the last command anyway.
Test PASSed. |
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.
Some comments
python/ray/monitor.py
Outdated
@@ -507,8 +506,8 @@ def run(self): | |||
log.debug("{} dead local schedulers, {} plasma managers total, {} " | |||
"dead plasma managers".format( | |||
len(self.dead_local_schedulers), | |||
(len(self.live_plasma_managers) + | |||
len(self.dead_plasma_managers)), | |||
(len(self.live_plasma_managers) + len( |
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.
this one is also a little odd..
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.
@alok can we revert this?
python/ray/experimental/state.py
Outdated
@@ -750,8 +750,8 @@ def micros_rel(ts): | |||
"name": | |||
"SubmitTask", | |||
"args": {}, | |||
"id": (parent_info["worker_id"] + | |||
str(micros(min(parent_times)))) | |||
"id": (parent_info["worker_id"] + str( |
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.
not a big fan of these
python/ray/experimental/state.py
Outdated
@@ -825,8 +825,8 @@ def micros_rel(ts): | |||
"name": | |||
"SubmitTask", | |||
"args": {}, | |||
"id": (parent_info["worker_id"] + | |||
str(micros(min(parent_times)))) | |||
"id": (parent_info["worker_id"] + str( |
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.
not a big fan of these
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.
@alok can we revert this?
Added some trailing commas to make certain blocks neater. This style uses more vertical space but is (IMO) significantly more readable for a lot of code since you can just sort of scan each block independently since they're clearly delineated from each other. Feel free to revert to the last commit
@richardliaw See the latest commit where I apply the style specified in the config file. I went in and manually tweaked some code by adding trailing commas so the formatter would do the right thing. I think it fixed all your comments and hopefully looks fine for the rest. If not, feel free to revert it. |
Test FAILed. |
OK I think there's too much vertical space as of this most recent commit; would you be willing to revert? |
This reverts commit 4579266.
Done. |
Test PASSed. |
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 requests to change; otherwise looks good overall.
python/ray/experimental/state.py
Outdated
@@ -825,8 +825,8 @@ def micros_rel(ts): | |||
"name": | |||
"SubmitTask", | |||
"args": {}, | |||
"id": (parent_info["worker_id"] + | |||
str(micros(min(parent_times)))) | |||
"id": (parent_info["worker_id"] + str( |
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.
@alok can we revert this?
python/ray/monitor.py
Outdated
@@ -507,8 +506,8 @@ def run(self): | |||
log.debug("{} dead local schedulers, {} plasma managers total, {} " | |||
"dead plasma managers".format( | |||
len(self.dead_local_schedulers), | |||
(len(self.live_plasma_managers) + | |||
len(self.dead_plasma_managers)), | |||
(len(self.live_plasma_managers) + len( |
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.
@alok can we revert this?
@richardliaw I'd rather tweak the formatting config until it ends up looking pretty to avoid ever having to worry about manual formatting. I want it to be reliable enough to become a git pre-push hook so no one ever has to comment about formatting again. |
It's better to have the occasional long line than to have very odd looking code. The codebase has long lines anyway, so it's not like they're totally verboten.
This should hopefully prevent some of the odder formatting.
This style looks fine to me and doesn't generally have a bunch of whitespace. A few trailing commas to split lines correctly and it should be satisfactory to everyone.
@richardliaw can you try out this style? i think it fixes (most) of your issues with the current one. |
Test FAILed. |
These should really be separate anyway.
Test PASSed. |
Hey @alok how did this become a 4k line PR? |
I made the mistake of actually committing the linting changes |
Check out https://github.com/alok/ray/tree/yapf-take-2 for a clean version |
OK great |
@richardliaw I ended up making a new branch from master and applying the necessary changes there. See #2083. |
What do these changes do?
.style.yapf
config fileyapf.sh
(IMO)Related issue number
No.