def get_actor( id: str, address: Optional[str] = None, timeout: int = DEFAULT_RPC_TIMEOUT, _explain: bool = False, ) -> Optional[ActorState]: return StateApiClient(address=address).get(StateResource.ACTORS, id, GetApiOptions(timeout=timeout), _explain=_explain)
def get_objects( id: str, address: Optional[str] = None, timeout: int = DEFAULT_RPC_TIMEOUT, _explain: bool = False, ) -> List[ObjectState]: return StateApiClient(api_server_address=address).get( StateResource.OBJECTS, id, GetApiOptions(timeout=timeout), _explain=_explain, )
def get_task( id: str, address: Optional[str] = None, timeout: int = DEFAULT_RPC_TIMEOUT, _explain: bool = False, ) -> Optional[TaskState]: return StateApiClient(api_server_address=address).get( StateResource.TASKS, id, GetApiOptions(timeout=timeout), _explain=_explain, )
def get_placement_group( id: str, address: Optional[str] = None, timeout: int = DEFAULT_RPC_TIMEOUT, _explain: bool = False, ) -> Optional[PlacementGroupState]: return StateApiClient(api_server_address=address).get( StateResource.PLACEMENT_GROUPS, id, GetApiOptions(timeout=timeout), _explain=_explain, )
def get( resource: str, id: str, address: Optional[str], timeout: float, ): """ Get RESOURCE by ID. RESOURCE is the name of the possible resources from `StateResource`, i.e. 'workers', 'actors', 'nodes', ... NOTE: We currently DO NOT support get by id for jobs and runtime-envs Example: ``` ray get nodes <node-id> ray get workers <worker-id> ``` """ # All resource names use '_' rather than '-'. But users options have '-' resource = StateResource(resource.replace("-", "_")) # Get the state API server address from ray if not provided by user api_server_address = address if address else get_api_server_url() # Create the State API server and put it into context logger.debug(f"Create StateApiClient at {api_server_address}...") client = StateApiClient(api_server_address=api_server_address, ) options = GetApiOptions(timeout=timeout, ) # If errors occur, exceptions will be thrown. data = client.get( resource=resource, id=id, options=options, _explain=_should_explain(AvailableFormat.YAML), ) # Print data to console. print( format_list_api_output( state_data=data, format=AvailableFormat.YAML, ))