Пример #1
0
 def actor_checkpoint_info(self, actor_id):
     """Get checkpoint info for the given actor id.
      Args:
         actor_id: Actor's ID.
      Returns:
         A dictionary with information about the actor's checkpoint IDs and
         their timestamps.
     """
     self._check_connected()
     message = self._execute_command(
         actor_id,
         "RAY.TABLE_LOOKUP",
         gcs_utils.TablePrefix.Value("ACTOR_CHECKPOINT_ID"),
         "",
         actor_id.binary(),
     )
     if message is None:
         return None
     gcs_entry = gcs_utils.GcsEntry.FromString(message)
     entry = gcs_utils.ActorCheckpointIdData.FromString(
         gcs_entry.entries[0])
     checkpoint_ids = [
         ray.ActorCheckpointID(checkpoint_id)
         for checkpoint_id in entry.checkpoint_ids
     ]
     return {
         "ActorID": ray.utils.binary_to_hex(entry.actor_id),
         "CheckpointIds": checkpoint_ids,
         "Timestamps": list(entry.timestamps),
     }
Пример #2
0
        def load_checkpoint(self, actor_id, available_checkpoints):
            actor_id = actor_id.hex()
            filename = self.checkpoint_dir + actor_id
            # Load checkpoint from the file.
            if not os.path.isfile(filename):
                return None

            available_checkpoint_ids = [
                c.checkpoint_id for c in available_checkpoints
            ]
            with open(filename, "r") as f:
                for line in f:
                    checkpoint_id, value = line.strip().split(" ")
                    checkpoint_id = ray.ActorCheckpointID(
                        ray.utils.hex_to_binary(checkpoint_id))
                    if checkpoint_id in available_checkpoint_ids:
                        self.value = int(value)
                        self.resumed_from_checkpoint = True
                        return checkpoint_id
                return None
Пример #3
0
 def actor_checkpoint_info(self, actor_id):
     """Get checkpoint info for the given actor id.
      Args:
         actor_id: Actor's ID.
      Returns:
         A dictionary with information about the actor's checkpoint IDs and
         their timestamps.
     """
     self._check_connected()
     message = self._execute_command(
         actor_id,
         "RAY.TABLE_LOOKUP",
         ray.gcs_utils.TablePrefix.ACTOR_CHECKPOINT_ID,
         "",
         actor_id.binary(),
     )
     if message is None:
         return None
     gcs_entry = ray.gcs_utils.GcsTableEntry.GetRootAsGcsTableEntry(
         message, 0)
     entry = (
         ray.gcs_utils.ActorCheckpointIdData.GetRootAsActorCheckpointIdData(
             gcs_entry.Entries(0), 0))
     checkpoint_ids_str = entry.CheckpointIds()
     num_checkpoints = len(checkpoint_ids_str) // ID_SIZE
     assert len(checkpoint_ids_str) % ID_SIZE == 0
     checkpoint_ids = [
         ray.ActorCheckpointID(
             checkpoint_ids_str[(i * ID_SIZE):((i + 1) * ID_SIZE)])
         for i in range(num_checkpoints)
     ]
     return {
         "ActorID": ray.utils.binary_to_hex(entry.ActorId()),
         "CheckpointIds": checkpoint_ids,
         "Timestamps": [
             entry.Timestamps(i) for i in range(num_checkpoints)
         ],
     }