def save( self, trial: Trial, storage: str = _TuneCheckpoint.PERSISTENT, result: Optional[Dict] = None, ) -> _TuneCheckpoint: """Saves the trial's state to a checkpoint asynchronously. Args: trial: The trial to be saved. storage: Where to store the checkpoint. Defaults to PERSISTENT. result: The state of this trial as a dictionary to be saved. If result is None, the trial's last result will be used. Returns: Checkpoint object, or None if an Exception occurs. """ logger.debug(f"saving trial {trial}") result = result or trial.last_result with self._change_working_directory(trial): if storage == _TuneCheckpoint.MEMORY: value = trial.runner.save_to_object.remote() checkpoint = _TuneCheckpoint(storage, value, result) trial.on_checkpoint(checkpoint) else: value = trial.runner.save.remote() checkpoint = _TuneCheckpoint(storage, value, result) trial.saving_to = checkpoint self._futures[value] = (ExecutorEventType.SAVING_RESULT, trial) return checkpoint
def checkpoint(self): return _TuneCheckpoint(_TuneCheckpoint.MEMORY, "None", {})