-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Add generic item support for queue #46849
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
base: master
Are you sure you want to change the base?
Conversation
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 is awesome! QQ; is it possible to add unit tests here? https://github.com/ray-project/ray/blob/master/python/ray/tests/test_typing.py
also there are some unit tests failures |
The error has something to do with the docs not building. Unfortunately I'm not super familiar with readthedocs, it's something to do with generic types.
|
can you first try adding a unit test? If it still fails, I can help resolving this |
Hi bumping this |
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.
@haarisr Thanks for the contribution! Could you please rebase and address the comments?
@PublicAPI(stability="beta") | ||
class Queue: | ||
class Queue(Generic[T]): |
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.
consider updating the docstring to mention generic support with a brief usage example.
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.
Will do
int_queue = Queue[int]() | ||
float_item: int | ||
for i in float_list: | ||
int_queue.put(i) |
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.
what do the tests actually assert?
Also, can we add tests for the async variants (put_async / get_async) so you’re sure static checkers handle those too?
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.
Theres a test in python/ray/tests/test_typing.py
that runs the file and checks the error status of mypy on the entire file instead of each test (which is seperated by a comment right now)
I don't think that is the best way to go about it.
Sure I can add those tests too.
Signed-off-by: haaris <haarisrahman@gmail.com>
Signed-off-by: haaris <haarisrahman@gmail.com>
b51bba0
to
e46b58d
Compare
Signed-off-by: Haaris Rahman <haarisrahman@gmail.com>
Signed-off-by: Haaris Rahman <haarisrahman@gmail.com>
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
Why are these changes needed?
Add generic support for
queue
. This allows thequeue
to be templated over any type allowing for type checkers to work better.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.