-
Notifications
You must be signed in to change notification settings - Fork 7k
move import_thread to a separate file #2349
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
Conversation
python/ray/import_thread.py
Outdated
| from __future__ import print_function | ||
|
|
||
| import pickle | ||
| import ray |
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.
import ray should be grouped with the other ray imports below.
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.
The standard style of my previous company is putting all imports before all from ... imports. I checked pep8 and google style, they doesn't seem to have a particular rule regarding this, but this style looks cleaner to me. Do we want to consider this? (That being said, I'll follow the current style in this PR.)
Also, I'm seeing something like import ray.ray_constants as ray_constants, I think we should avoid this and use from ray import ray_constants
python/ray/import_thread.py
Outdated
|
|
||
|
|
||
| class ImportThread(object): | ||
| """ |
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.
The docstring should contain a one-line description, e.g.,
"""Brief one-line description of the class.
More details....
Attributes:
worker: ...
"""
python/ray/import_thread.py
Outdated
| function_id = ray.ObjectID(function_id_str) | ||
| function_name = function_name.decode("ascii") | ||
| max_calls = int(max_calls) | ||
| module = module.decode("ascii") |
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.
If you rebase on the current master, all of the decode("ascii") lines should be replaced by ray.utils.decode. E.g., see eaa1110.
This has better behavior in Python 2.
python/ray/import_thread.py
Outdated
| t.start() | ||
|
|
||
| def _run(self): | ||
| from ray.worker import log_span, WORKER_MODE |
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 of this code was changed in #2306
python/ray/import_thread.py
Outdated
| from __future__ import division | ||
| from __future__ import print_function | ||
|
|
||
| import pickle |
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 should not be pickle, it should be import ray.cloudpickle as pickle (grouped with the ray imports below)
|
(Copying my previous comment here because it was out-dated) The standard style of my previous company is putting all Also, I'm seeing something like |
|
Test FAILed. |
|
@raulchen We should defer to whatever the google style guide says (or any Python standards). @concretevitamin are you more familiar with this? As for Let's avoid usage of |
|
Test PASSed. |
|
hi @robertnishihara, And it uses I'll change the code according to the above rules. Also, |
|
Test FAILed. |
|
hi @robertnishihara, could you please help re-run the Travis CI? test failures look unrelated. Thank you! |
|
Close and reopen this PR to trigger Travis CI. |
|
jenkins, retest this please |
python/ray/import_thread.py
Outdated
| if self.mode != WORKER_MODE: | ||
| if key.startswith(b"FunctionsToRun"): | ||
| with profile( | ||
| "ray:import_function_to_run", |
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 the test failure in the "xray" Travis job is caused by the name changes in these profile statements. This PR changes them accidentally (due to the rebase). Do you see what I mean?
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 see. thank you for pointing out.
|
Test PASSed. |
|
Test PASSed. |
|
Test PASSed. |
|
Test PASSed. |
|
@robertnishihara this PR should be ready now. |
Move import thread and related functions to a separate file, and make it a class.
Note: this PR is simply a sanitizing refactor, it doesn't change any code logic. Next RP will change the import thread to use its own redis client and local scheduler client to address multi-threading issue. Previous discussion can be found at #2248.