def create_experiment_suite(xml, access_config, repetitions = None, duration = None, wait_guids = None): mode = None if access_config : (mode, launch, root_dir, log_level, communication, user, host, port, key, agent, sudo, environment_setup, clean_root) \ = get_access_config_params(access_config) if not mode or mode == DC.MODE_SINGLE_PROCESS: from nepi.core.execute import ExperimentSuite if not root_dir: root_dir = TempDir() else: root_dir = PermDir(access_config.get_attribute_value(DC.ROOT_DIRECTORY)) exp_suite = ExperimentSuite(xml, access_config, repetitions, duration, wait_guids) # inject reference to temporary dir, so that it gets cleaned # up at destruction time. exp_suite._tempdir = root_dir return exp_suite elif mode == DC.MODE_DAEMON: return ExperimentSuiteProxy(root_dir, log_level, xml, repetitions = repetitions, duration = duration, wait_guids = wait_guids, communication = communication, host = host, port = port, user = user, ident_key = key, agent = agent, sudo = sudo, environment_setup = environment_setup, clean_root = clean_root) raise RuntimeError("Unsupported access configuration '%s'" % mode)
def post_daemonize(self): from nepi.core.execute import ExperimentSuite self._experiment_suite = ExperimentSuite( self._experiment_xml, self._access_config, self._repetitions, self._duration, self._wait_guids)
class ExperimentSuiteServer(BaseServer): def __init__(self, root_dir, log_level, xml, repetitions, duration, wait_guids, communication = DC.ACCESS_LOCAL, host = None, port = None, user = None, ident_key = None, agent = None, sudo = False, environment_setup = "", clean_root = False): super(ExperimentSuiteServer, self).__init__(root_dir, log_level, environment_setup = environment_setup, clean_root = clean_root) access_config = AccessConfiguration() access_config.set_attribute_value(DC.ROOT_DIRECTORY, root_dir) access_config.set_attribute_value(DC.LOG_LEVEL, log_level) access_config.set_attribute_value(DC.DEPLOYMENT_ENVIRONMENT_SETUP, environment_setup) if user: access_config.set_attribute_value(DC.DEPLOYMENT_USER, user) if host: access_config.set_attribute_value(DC.DEPLOYMENT_HOST, host) if port: access_config.set_attribute_value(DC.DEPLOYMENT_PORT, port) if agent: access_config.set_attribute_value(DC.USE_AGENT, agent) if sudo: acess_config.set_attribute_value(DC.USE_SUDO, sudo) if ident_key: access_config.set_attribute_value(DC.DEPLOYMENT_KEY, ident_key) if communication: access_config.set_attribute_value(DC.DEPLOYMENT_COMMUNICATION, communication) if clean_root: access_config.set_attribute_value(DC.CLEAN_ROOT, clean_root) self._experiment_xml = xml self._duration = duration self._repetitions = repetitions self._wait_guids = wait_guids self._access_config = access_config self._experiment_suite = None def post_daemonize(self): from nepi.core.execute import ExperimentSuite self._experiment_suite = ExperimentSuite( self._experiment_xml, self._access_config, self._repetitions, self._duration, self._wait_guids) @Marshalling.handles(CURRENT) @Marshalling.args() @Marshalling.retval(int) def current(self): return self._experiment_suite.current() @Marshalling.handles(STATUS) @Marshalling.args() @Marshalling.retval(int) def status(self): return self._experiment_suite.status() @Marshalling.handles(FINISHED) @Marshalling.args() @Marshalling.retval(Marshalling.bool) def is_finished(self): return self._experiment_suite.is_finished() @Marshalling.handles(ACCESS_CONFIGURATIONS) @Marshalling.args() @Marshalling.retval( Marshalling.pickled_data ) def get_access_configurations(self): return self._experiment_suite.get_access_configurations() @Marshalling.handles(START) @Marshalling.args() @Marshalling.retvoid def start(self): self._experiment_suite.start() @Marshalling.handles(SHUTDOWN) @Marshalling.args() @Marshalling.retvoid def shutdown(self): self._experiment_suite.shutdown() @Marshalling.handles(CURRENT_ACCESS_CONFIG) @Marshalling.args() @Marshalling.retval( Marshalling.pickled_data ) def get_current_access_config(self): return self._experiment_suite.get_current_access_config()