

def _prepare_resume(self):
    ' Prepares the continuation of a crashed trajectory '
    if (not self._resumable):
        raise RuntimeError('If you create an environment to resume a run, you need to set `continuable=True`.')
    if (not self._do_single_runs):
        raise RuntimeError('You cannot resume a run if you did create an environment with `do_single_runs=False`.')
    ext._resume_path = os.path.join(self._resume_folder, self._trajectory_name)
    cnt_filename = os.path.join(self._resume_path, 'environment.ecnt')
    cnt_file = open(cnt_filename, 'rb')
    resume_dict = dill.load(cnt_file)
    cnt_file.close()
    traj = resume_dict['trajectory']
    config_name = ('config.environment.%s.trajectory.name' % self.name)
    if self._traj.f_contains(config_name, shortcuts=False):
        param = self._traj.f_get(config_name, shortcuts=False)
        param.f_unlock()
        param.f_set(traj.v_name)
        param.f_lock()
    config_name = ('config.environment.%s.trajectory.timestamp' % self.name)
    if self._traj.f_contains(config_name, shortcuts=False):
        param = self._traj.f_get(config_name, shortcuts=False)
        param.f_unlock()
        param.f_set(traj.v_timestamp)
        param.f_lock()
    if (not traj.config.environment.f_contains(self.name, shortcuts=False)):
        traj._merge_config(self._traj)
    self._traj = traj
    self._runfunc = resume_dict['runfunc']
    self._args = resume_dict['args']
    self._kwargs = resume_dict['kwargs']
    self._postproc = resume_dict['postproc']
    self._postproc_args = resume_dict['postproc_args']
    self._postproc_kwargs = resume_dict['postproc_kwargs']
    self._traj.v_full_copy = resume_dict['full_copy']
    self._traj.f_load(load_parameters=pypetconstants.LOAD_NOTHING, load_derived_parameters=pypetconstants.LOAD_NOTHING, load_results=pypetconstants.LOAD_NOTHING, load_other_data=pypetconstants.LOAD_NOTHING)
    result_list = []
    full_filename_list = []
    for filename in os.listdir(self._resume_path):
        (_, ext) = os.path.splitext(filename)
        if (ext != '.rcnt'):
            continue
        full_filename = os.path.join(self._resume_path, filename)
        cnt_file = open(full_filename, 'rb')
        result_list.append(dill.load(cnt_file))
        cnt_file.close()
        full_filename_list.append(full_filename)
    new_result_list = []
    for result_tuple in result_list:
        run_information = result_tuple[1]
        self._traj._update_run_information(run_information)
        new_result_list.append(result_tuple[0])
    result_sort(new_result_list)
    config_name = ('environment.%s.resumed' % self.name)
    if (not (config_name in self._traj)):
        self._traj.f_add_config(Parameter, config_name, True, comment='Added if a crashed trajectory was continued.')
    self._logger.info(('I will resume trajectory `%s`.' % self._traj.v_name))
    return new_result_list

dataset/ETHPy150Open SmokinCaterpillar/pypet/pypet/environment.py Environment._prepare_resume/VarMisuse@46/145 `self`->`ext`