class_docstr: A helper class to group updates and operations on an Instance object defined
  in instance_manager.proto
class_docstr_tok: ["A","helper","class","to","group","updates","and","operations","on","an","Instance","object","defined","in","instance_manager.proto"]
docstr: Transitions the instance to the new state.
  
  Args:
      instance: The instance to update.
      new_instance_status: The new status to transition to.
      details: The details of the transition.
  
  Raises:
      InvalidInstanceStatusError if the transition is not allowed.
docstr_tok: ["Transitions","the","instance","to","the","new","state",".","Args",":","instance",":","The","instance","to","update",".","new_instance_status",":","The","new","status","to","transition","to",".","details",":","The","details","of","the","transition",".","Raises",":","InvalidInstanceStatusError","if","the","transition","is","not","allowed","."]
code: def set_status(
      instance: Instance,
      new_instance_status: Instance.InstanceStatus,
      details: str = "",
  ):
      """Transitions the instance to the new state.
  
      Args:
          instance: The instance to update.
          new_instance_status: The new status to transition to.
          details: The details of the transition.
  
      Raises:
          InvalidInstanceStatusError if the transition is not allowed.
      """
      if (
          new_instance_status
          not in InstanceUtil.get_valid_transitions()[instance.status]
      ):
          raise InvalidInstanceStatusError(
              instance_id=instance.instance_id,
              cur_status=instance.status,
              new_status=new_instance_status,
          )
      instance.status = new_instance_status
      InstanceUtil._record_status_transition(
          instance, new_instance_status, details
      )
  
file_path: ray/python/ray/autoscaler/v2/instance_manager/instance_manager.py
imports: import logging
  import time
  from abc import ABC, abstractmethod
  from typing import Dict, List, Optional, Set
  from ray.autoscaler.v2.schema import InvalidInstanceStatusError
  from ray.core.generated.instance_manager_pb2 import GetInstanceManagerStateReply, GetInstanceManagerStateRequest, Instance, UpdateInstanceManagerStateReply, UpdateInstanceManagerStateRequest
label_desc: Use image node_id 4 for calling the InstanceUtil obj's underlying member method code with example usage: obj.set_status(instance, new_instance_status, details) without return types