def create_runner(self, with_persistence=True, **kwargs): """Create and return a new runner :param with_persistence: create a runner with persistence enabled :type with_persistence: bool :return: a new runner instance :rtype: :class:`aiida.engine.runners.Runner` """ from aiida.engine import runners config = self.get_config() profile = self.get_profile() poll_interval = 0.0 if profile.is_test_profile else config.get_option( 'runner.poll.interval', profile.name) settings = {'rmq_submit': False, 'poll_interval': poll_interval} settings.update(kwargs) if 'communicator' not in settings: # Only call get_communicator if we have to as it will lazily create settings['communicator'] = self.get_communicator() if with_persistence and 'persister' not in settings: settings['persister'] = self.get_persister() return runners.Runner(**settings)
def create_runner(self, with_persistence: bool = True, **kwargs: Any) -> 'Runner': """Create and return a new runner :param with_persistence: create a runner with persistence enabled :return: a new runner instance """ from aiida.common import ConfigurationError from aiida.engine import runners config = self.get_config() profile = self.get_profile() if profile is None: raise ConfigurationError( 'Could not determine the current profile. Consider loading a profile using `aiida.load_profile()`.' ) poll_interval = 0.0 if profile.is_test_profile else config.get_option( 'runner.poll.interval', profile.name) settings = {'rmq_submit': False, 'poll_interval': poll_interval} settings.update(kwargs) if 'communicator' not in settings: # Only call get_communicator if we have to as it will lazily create settings['communicator'] = self.get_communicator() if with_persistence and 'persister' not in settings: settings['persister'] = self.get_persister() return runners.Runner(**settings)