-
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
Enable to specify driver id by user. #3084
Conversation
python/ray/worker.py
Outdated
@@ -1664,6 +1667,7 @@ def init(redis_address=None, | |||
plasma_directory=None, | |||
huge_pages=False, | |||
include_webui=True, | |||
worker_id=None, |
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 this is the driver_id
then it needs to be called driver_id
.
python/ray/worker.py
Outdated
@@ -2017,7 +2026,10 @@ def connect(info, | |||
assert not worker.connected, error_message | |||
assert worker.cached_functions_to_run is not None, error_message | |||
# Initialize some fields. | |||
worker.worker_id = random_string() | |||
if worker_id is None: |
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.
We should do some type checking. I think we want to assert that it is a Ray ObjectID or that it is 20 bytes or something like that. All of that is a bit ugly unfortunately.
I have mixed feelings about this. I think we want to restrict driver_id's to have type |
Test PASSed. |
Test PASSed. |
@robertnishihara Thanks a lot for your comments about this. I have addressed some comments: It's too awkward for me to do type checking for these codes. As @robertnishihara mentioned, which type should Another question I found is # Initialize some fields.
if mode is WORKER_MODE:
worker.worker_id = random_string()
else:
# This is the code path of driver mode.
if driver_id is None:
driver_id = ray.ObjectID(random_string())
elif isinstance(driver_id, (bytes, str)):
if len(driver_id) is not ray_constants.ID_SIZE:
raise Exception("The length of given driver id str must be 20.")
driver_id = ray.ObjectID(driver_id)
elif not isinstance(driver_id, ray.ObjectID):
raise Exception("The type of given driver id must be str or ray.ObjectID.")
worker.worker_id = driver_id.id() We should assume I think the better way to solve it is to use |
@guoyuhong cc |
Test PASSed. |
Test PASSed. |
@guoyuhong @jovan-wong what is the use case for specifying the driver ID? |
@robertnishihara We will enable cross-language calling which makes streaming work smoothly. Before Java Driver calling a Python worker, the python code should be deployed to a path or vise versa. Knowing the driver Id before hand will enable use to deploy the python/java code to a directory related to the driver id. |
Another purpose is that we want to have an external 'job manager' that runs all drivers with pre-defined driver ids, so it can manage the drivers by the ids. @robertnishihara do you have any other questions? This PR looks good to me. |
Test FAILed. |
Test FAILed. |
python/ray/worker.py
Outdated
if driver_id is None: | ||
driver_id = ray.ObjectID(random_string()) | ||
|
||
elif isinstance(driver_id, (bytes, 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.
Let's check that it is bytes
for Python 2 and str
for Python 3.
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.
actually, for now, let's require it to be an ObjectID
. I think the more restrictive we make it the better since it makes it easier to change later.
python/ray/worker.py
Outdated
@@ -1731,6 +1736,7 @@ def init(redis_address=None, | |||
Store with hugetlbfs support. Requires plasma_directory. | |||
include_webui: Boolean flag indicating whether to start the web | |||
UI, which is a Jupyter notebook. | |||
driver_id: The id of driver, and it will be ignored in non-driver 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.
id -> ID
remove the stuff after the ,
, there is no such thing as "non-driver" 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.
at least from the perspective of the user and ray.init
, there is no such thing as "non-driver" 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.
Thanks! I left some comments.
2be4a4b
to
a484a9c
Compare
Add type checking and address comments. Fix small thing. Add ut. Fix lint Remove useless code. Address comments.
a484a9c
to
202d6bd
Compare
@robertnishihara Tks 4 ur comments. |
Test FAILed. |
Test PASSed. |
Test PASSed. |
@jovan-wong thanks, I fixed some linting errors. It can be merged once tests pass. |
Test PASSed. |
What do these changes do?
It's very useful for us to specify driver id to a driver.
In Java, we could specify it by
ray.conf
, and in Python, we should do it bydef init()
:If we don't specify one, it will generate a random for us.
Related issue number
N/A