def _execute_runs(self, pipeline):
        """ Starts the individual single runs.

        Starts runs sequentially or initiates multiprocessing.

        :param pipeline:

            A pipeline function producing the run function the corresponding arguments
            and postprocessing function and arguments

        :return:

            List of tuples, where each tuple contains the run idx and the result.

        """
        if self._start_timestamp is None:
            self._start_timestamp = time.time()

        if self._map_arguments and self._resumable:
            raise ValueError('You cannot use `run_map` or `pipeline_map` in combination '
                             'with continuing option.')

        if self._sumatra_project is not None:
            self._prepare_sumatra()

        if pipeline is not None:
            results = []
            self._prepare_runs(pipeline)
        else:
            results = self._prepare_resume()

        if self._runfunc is not None:
            self._traj._run_by_environment = True
            if self._graceful_exit:
                sigint_handling.start()
            try:
                self._inner_run_loop(results)
            finally:
                self._traj._run_by_environment = False
                self._stop_iteration = False
                if self._graceful_exit:
                    sigint_handling.finalize()

        self._add_wildcard_config()

        if self._automatic_storing:
            self._logger.info('\n************************************************************\n'
                              'STARTING FINAL STORING of trajectory\n`%s`'
                              '\n************************************************************\n' %
                              self._traj.v_name)
            self._traj.f_store()
            self._logger.info('\n************************************************************\n'
                              'FINISHED FINAL STORING of trajectory\n`%s`.'
                              '\n************************************************************\n' %
                              self._traj.v_name)

        self._finish_timestamp = time.time()

        findatetime = datetime.datetime.fromtimestamp(self._finish_timestamp)
        startdatetime = datetime.datetime.fromtimestamp(self._start_timestamp)

        self._runtime = str(findatetime - startdatetime)

        conf_list = []
        config_name = 'environment.%s.start_timestamp' % self.name
        if not self._traj.f_contains('config.' + config_name):
            conf1 = self._traj.f_add_config(Parameter, config_name, self._start_timestamp,
                                    comment='Timestamp of starting of experiment '
                                            '(when the actual simulation was '
                                            'started (either by calling `run`, '
                                            '`resume`, or `pipeline`).')
            conf_list.append(conf1)

        config_name = 'environment.%s.finish_timestamp' % self.name
        if not self._traj.f_contains('config.' + config_name):
            conf2 = self._traj.f_add_config(Parameter, config_name, self._finish_timestamp,
                                            comment='Timestamp of finishing of an experiment.')
        else:
            conf2 = self._traj.f_get('config.' + config_name)
            conf2.f_unlock()
            conf2.f_set(self._finish_timestamp)
        conf_list.append(conf2)

        config_name = 'environment.%s.runtime' % self.name
        if not self._traj.f_contains('config.' + config_name):
            conf3 = self._traj.f_add_config(Parameter, config_name, self._runtime,
                                            comment='Runtime of whole experiment.')
        else:
            conf3 = self._traj.f_get('config.' + config_name)
            conf3.f_unlock()
            conf3.f_set(self._runtime)
        conf_list.append(conf3)

        if self._automatic_storing:
            self._traj.f_store_items(conf_list, store_data=pypetconstants.OVERWRITE_DATA)

        if hasattr(self._traj.v_storage_service, 'finalize'):
            # Finalize the storage service if this is supported
            self._traj.v_storage_service.finalize()

        incomplete = []
        for run_name in self._traj.f_get_run_names():
            if not self._traj._is_completed(run_name):
                incomplete.append(run_name)
        if len(incomplete) > 0:
            self._logger.error('Following runs of trajectory `%s` '
                               'did NOT complete: `%s`' % (self._traj.v_name,
                                                           ', '.join(incomplete)))
        else:
            self._logger.info('All runs of trajectory `%s` were completed successfully.' %
                              self._traj.v_name)

        if self._sumatra_project is not None:
            self._finish_sumatra()

        return results
dataset/ETHPy150Open SmokinCaterpillar/pypet/pypet/environment.py/Environment._execute_runs/original