-
Notifications
You must be signed in to change notification settings - Fork 6.7k
[Core][Label Scheduling 1/n]Add NodeLabelSchedulingStrategy API in python #36418
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
e96d370
to
8e53f5c
Compare
8e53f5c
to
b2b6d13
Compare
b2b6d13
to
8c79eda
Compare
LabelMatchExpressionsT = Dict[str, LabelMatchExpression] | ||
|
||
|
||
@PublicAPI(stability="beta") |
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 start with alpha.
|
||
|
||
@PublicAPI(stability="beta") | ||
class NodeLabelSchedulingStrategy: |
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.
Can we move this file into scheduling_strategies.py
? All the other strategies are defined there.
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.
Fixed
8c79eda
to
134e094
Compare
a3625e3
to
db02d91
Compare
self.soft = transfer_map_to_expresions(soft) | ||
|
||
|
||
def transfer_map_to_expresions(map_expressions: LabelMatchExpressionsT): |
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.
_convert_map_to_label_math_expressions
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 change to _convert_map_to_expressions
. more concise.
"The value of label match expression in node label " | ||
"scheduling strategy must be created by " | ||
"`IN` or `NOT_IN` or`EXIST` or `DOES_NOT_EXIST`." |
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 value of label match expression in node label " | |
"scheduling strategy must be created by " | |
"`IN` or `NOT_IN` or`EXIST` or `DOES_NOT_EXIST`." | |
"The value of label match expression in node label " | |
"scheduling strategy must be " | |
"`In` or `NotIn` or`Exists` or `DoesNotExist` operator." |
db02d91
to
0aa8344
Compare
pass | ||
|
||
|
||
class LabelMatchExpression: |
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.
class LabelMatchExpression: | |
class _LabelMatchExpression: |
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.
fixed
"""The schedling strategy of node Affinity with labels | ||
Simplified usage: | ||
scheduling_strategy=NodeLabelSchedulingStrategy({ | ||
"region": IN("us"), | ||
"gpu_type": EXISTS() | ||
}) | ||
""" |
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 schedling strategy of node Affinity with labels | |
Simplified usage: | |
scheduling_strategy=NodeLabelSchedulingStrategy({ | |
"region": IN("us"), | |
"gpu_type": EXISTS() | |
}) | |
""" | |
"""Label based node affinity scheduling strategy | |
scheduling_strategy=NodeLabelSchedulingStrategy({ | |
"region": IN("us"), | |
"gpu_type": EXISTS() | |
}) | |
""" |
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.
fxied
0aa8344
to
93e0a61
Compare
@@ -72,9 +72,90 @@ def __init__( | |||
self._fail_on_unavailable = _fail_on_unavailable | |||
|
|||
|
|||
def _validate_values(values): | |||
if values is None or len(values) == 0: | |||
raise ValueError("The value of lable cannot be empty.") |
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.
lable -> label
|
||
for value in values: | ||
if not isinstance(value, str): | ||
raise ValueError("The value of lable must be string.") |
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.
Be a little more specific here like Expected value {value} in position {index} to be of type 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.
Fixed
Before this can be merged, the error messages should be improved:
Think about the user experience: They will get the error, and they will need to find out exactly which value caused the error. Currently that is extremely hard at best. |
93e0a61
to
9b850dd
Compare
I have fixed. Can you help me review again? |
@@ -72,9 +72,95 @@ def __init__( | |||
self._fail_on_unavailable = _fail_on_unavailable | |||
|
|||
|
|||
def _validate_values(values): | |||
if values is None or len(values) == 0: |
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 values is None or len(values) == 0: | |
if not values: |
@@ -72,9 +72,95 @@ def __init__( | |||
self._fail_on_unavailable = _fail_on_unavailable | |||
|
|||
|
|||
def _validate_values(values): | |||
if values is None or len(values) == 0: | |||
raise ValueError("The value of label cannot be empty.") |
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 variadic parameter of the In operator must be a non-empty tuple: e.g. In("value1", "value2")
.
3edceb9
to
8bb6b7c
Compare
…thon Signed-off-by: LarryLian <554538252@qq.com>
8bb6b7c
to
6071810
Compare
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.
@jjyao The ideal error message would also include which label the error message is referring (e.g. "gpu_type" in the example) :)
Discussed offline: currently the validation is done inside the operator constructor and we don't have the label key information. User should be able to rely on the stack trace to locate which operator is invalid without knowing the label key. |
…thon (ray-project#36418) Signed-off-by: LarryLian <554538252@qq.com>
…thon (ray-project#36418) Signed-off-by: LarryLian <554538252@qq.com> Signed-off-by: NripeshN <nn2012@hw.ac.uk>
…thon (ray-project#36418) Signed-off-by: LarryLian <554538252@qq.com> Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
…thon (ray-project#36418) Signed-off-by: LarryLian <554538252@qq.com> Signed-off-by: Victor <vctr.y.m@example.com>
Why are these changes needed?
After our offline discussion, we have come up with the following plan. This API plan will review and finalization by more people in the future.
Complete form of API:
User also can use more simple api:
Related issue number
[Core][Labels Scheduling]Finalize the new node affinity scheduling with node labels API in the Python worker #36419
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.