ray-project / ray

Ray is an AI compute engine. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
33.66k stars 5.72k forks source link

[core] autocomplete for ray.remote wrapped functions/classes #24415

Open richardliaw opened 2 years ago

richardliaw commented 2 years ago

Description

Autocomplete functionality for ray.remote decorated/wrapped function/classes

Use case

As a library developer, I may expose Ray Remote as a primitive to my developers. However, decorators currently completely swallow the autocomplete functionality.

Can we better support this?

https://discuss.ray.io/t/autocomplete-in-pycharm/4237

pcmoritz commented 2 years ago

Related discussion about IDE complete functionality and type stubs by @tiangolo : https://github.com/python/typing/discussions/1163

mbbyn commented 1 year ago

We could still have basic auto-complete support without having "proper" typing/type hint constructs.

I'm not sure if it's desirable or not, but ray could use a simple TypeVar to passthrough the decorated class as-is. Granted, this will not be the "proper" spec, namely it won't have ObjectRef nor remote types correctly shows, but at least it will auto-complete the function names, which reduces the chance of typing errors.

I believe it would be a nice feature many users can benefit from in the interim while we wait for better typing support from Python.