object_ref.pyi 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # source: object_ref.pxi
  2. import asyncio
  3. import concurrent.futures
  4. from typing import Any, Awaitable, Callable, Generator, Optional, TypeVar, Union
  5. from ray.includes.unique_ids import BaseID, JobID, TaskID
  6. _T = TypeVar("_T")
  7. def _set_future_helper(
  8. result: _T,
  9. *,
  10. py_future: Union[asyncio.Future[_T], concurrent.futures.Future[_T]],
  11. ) -> None: ...
  12. _OR = TypeVar("_OR", bound=ObjectRef)
  13. class ObjectRef(BaseID, Awaitable[_T]):
  14. def __init__(
  15. self, id: bytes, owner_addr: str = "", call_site_data: str = "",
  16. skip_adding_local_ref: bool = False, tensor_transport: Optional[str] = None) -> None: ...
  17. def __dealloc__(self) -> None: ...
  18. def task_id(self) -> TaskID: ...
  19. def job_id(self) -> JobID: ...
  20. def owner_address(self) -> str: ...
  21. def call_site(self) -> str: ...
  22. @classmethod
  23. def size(cls) -> int: ...
  24. def _set_id(self, id: bytes) -> None: ...
  25. @classmethod
  26. def nil(cls: type[_OR]) -> _OR: ...
  27. @classmethod
  28. def from_random(cls: type[_OR]) -> _OR: ...
  29. def future(self) -> concurrent.futures.Future[_T]:
  30. """Wrap ObjectRef with a concurrent.futures.Future
  31. Note that the future cancellation will not cancel the correspoding
  32. task when the ObjectRef representing return object of a task.
  33. Additionally, future.running() will always be ``False`` even if the
  34. underlying task is running.
  35. """
  36. ...
  37. def __await__(self) -> Generator[Any, None, _T]: ...
  38. def as_future(self, _internal=False) -> asyncio.Future[_T]:
  39. """Wrap ObjectRef with an asyncio.Future.
  40. Note that the future cancellation will not cancel the correspoding
  41. task when the ObjectRef representing return object of a task.
  42. """
  43. ...
  44. def _on_completed(self, py_callback: Callable[[_T], None]):
  45. """Register a callback that will be called after Object is ready.
  46. If the ObjectRef is already ready, the callback will be called soon.
  47. The callback should take the result as the only argument. The result
  48. can be an exception object in case of task error.
  49. """
  50. ...
  51. def tensor_transport(self) -> int: ...