Saves execution state to `self._metadata_checkpoint_dir`.

        Overwrites the current session checkpoint, which starts when self
        is instantiated.

def checkpoint(self):
        """Saves execution state to `self._metadata_checkpoint_dir`.

        Overwrites the current session checkpoint, which starts when self
        is instantiated.
        """
        if not self._metadata_checkpoint_dir:
            return
        metadata_checkpoint_dir = self._metadata_checkpoint_dir
        if not os.path.exists(metadata_checkpoint_dir):
            os.makedirs(metadata_checkpoint_dir)
        runner_state = {
            "checkpoints": list(
                self.trial_executor.get_checkpoints().values()),
            "runner_data": self.__getstate__(),
            "timestamp": time.time()
        }
        tmp_file_name = os.path.join(metadata_checkpoint_dir,
                                     ".tmp_checkpoint")
        with open(tmp_file_name, "w") as f:
            json.dump(runner_state, f, indent=2, cls=_TuneFunctionEncoder)

        os.rename(
            tmp_file_name,
            os.path.join(metadata_checkpoint_dir,
                         TrialRunner.CKPT_FILE_TMPL.format(self._session_str)))
        return metadata_checkpoint_dir