unique_ids.pyi 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. from __future__ import annotations
  2. from typing import Tuple, TypeVar
  3. # backwards compatibility. Luckily circular references are fine in type stubs
  4. from ray._raylet import ObjectRef
  5. ObjectID = ObjectRef
  6. # implementations are in unique_ids.pxi
  7. def check_id(b: bytes, size: int = ...) -> None: ...
  8. _BID = TypeVar("_BID", bound=BaseID)
  9. class BaseID:
  10. @classmethod
  11. def from_binary(cls: type[_BID], id_bytes: bytes) -> _BID: ...
  12. @classmethod
  13. def from_hex(cls: type[_BID], hex_id: str | bytes) -> _BID: ...
  14. def binary(self) -> bytes: ...
  15. @classmethod
  16. def size(cls) -> int: ...
  17. def hex(self) -> str: ...
  18. def is_nil(self) -> bool: ...
  19. def __hash__(self) -> int: ...
  20. def __eq__(self, other: object) -> bool: ...
  21. def __ne__(self, other: object) -> bool: ...
  22. def __bytes__(self) -> bytes: ...
  23. def __hex__(self) -> str: ...
  24. def __repr__(self) -> str: ...
  25. def __str__(self) -> str: ...
  26. def __reduce__(self: _BID) -> Tuple[type[_BID], Tuple[bytes]]: ...
  27. def redis_shard_hash(self) -> int: ...
  28. _UID = TypeVar("_UID", bound=UniqueID)
  29. class UniqueID(BaseID):
  30. def __init__(self, id: bytes) -> None: ...
  31. @classmethod
  32. def nil(cls: type[_UID]) -> _UID: ...
  33. @classmethod
  34. def from_random(cls: type[_UID]) -> _UID: ...
  35. _TID = TypeVar("_TID", bound=TaskID)
  36. class TaskID(BaseID):
  37. def __init__(self, id: bytes) -> None: ...
  38. def actor_id(self) -> ActorID: ...
  39. def job_id(self) -> JobID: ...
  40. @classmethod
  41. def nil(cls: type[_TID]) -> _TID: ...
  42. @classmethod
  43. def for_fake_task(cls: type[_TID], job_id: JobID) -> _TID: ...
  44. @classmethod
  45. def for_driver_task(cls: type[_TID], job_id: JobID) -> _TID: ...
  46. @classmethod
  47. def for_actor_creation_task(cls: type[_TID], actor_id: ActorID) -> _TID: ...
  48. @classmethod
  49. def for_actor_task(cls: type[_TID], job_id: JobID, parent_task_id: TaskID,
  50. parent_task_counter: int, actor_id: ActorID) -> _TID: ...
  51. @classmethod
  52. def for_normal_task(cls: type[_TID], job_id: JobID, parent_task_id: TaskID, parent_task_counter: int) -> _TID: ...
  53. class NodeID(UniqueID): ...
  54. _JID = TypeVar("_JID", bound=JobID)
  55. class JobID(BaseID):
  56. def __init__(self, id: bytes) -> None: ...
  57. @classmethod
  58. def from_int(cls: type[_JID], value: int) -> _JID: ...
  59. @classmethod
  60. def nil(cls: type[_JID]) -> _JID: ...
  61. def int(self) -> int: ...
  62. class WorkerID(UniqueID): ...
  63. _AID = TypeVar("_AID", bound=ActorID)
  64. class ActorID(BaseID):
  65. def __init__(self, id: bytes) -> None: ...
  66. @classmethod
  67. def of(cls: type[_AID], job_id: JobID, parent_task_id: TaskID, parent_task_counter: int) -> _AID: ...
  68. @classmethod
  69. def nil(cls: type[_AID]) -> _AID: ...
  70. @classmethod
  71. def from_random(cls: type[_AID]) -> _AID: ...
  72. def _set_id(self, id: bytes) -> None: ...
  73. @property
  74. def job_id(self) -> JobID: ...
  75. class FunctionID(UniqueID): ...
  76. class ActorClassID(UniqueID): ...
  77. class ClusterID(UniqueID): ...
  78. _PGID = TypeVar("_PGID", bound=PlacementGroupID)
  79. class PlacementGroupID(BaseID):
  80. def __init__(self, id: bytes) -> None: ...
  81. @classmethod
  82. def from_random(cls: type[_PGID]) -> _PGID: ...
  83. @classmethod
  84. def of(cls: type[_PGID], job_id: JobID) -> _PGID: ...
  85. @classmethod
  86. def nil(cls: type[_PGID]) -> _PGID: ...