예제 #1
0
    def _parse_config(self, opt):
        """
        Parse config for task. Use this to parse all options and settings
        necessary to set the variables for the conversation
        """

        self.config = opt['config']
        self.overworld = self.config['overworld']
        self.world_path = self.config['world_path']
        self.world_module = shared_utils.get_world_module(self.world_path)
        self.task_configs = self.config['configs']
        self.max_workers = self.config['max_workers']
        self.opt['task'] = self.config['task_name']
        self.world_runner = MessengerWorldRunner(
            opt, self.world_path, self.max_workers, self, opt['is_debug']
        )  # Replace with base runner
        self.max_agents_for = {
            task: cfg.agents_required for task, cfg in self.task_configs.items()
        }
        self.onboard_map = {
            task: cfg.onboarding_name for task, cfg in self.task_configs.items()
        }
        self.taskworld_map = {
            task: cfg.task_name for task, cfg in self.task_configs.items()
        }
예제 #2
0
    def _parse_config(self, opt):
        """
        Parse config for task.

        Use this to parse all options and settings necessary to set the variables for
        the conversation
        """

        self.config = opt['config']
        self.overworld = self.config['overworld']
        self.world_path = self.config['world_path']
        self.world_module = shared_utils.get_world_module(self.world_path)
        self.task_configs = self.config['configs']
        self.max_workers = self.config['max_workers']
        self.opt['task'] = self.config['task_name']
        # Deepcopy the opts so the manager opts aren't changed by the world runner
        self.runner_opt = copy.deepcopy(opt)
        self.world_runner = ChatServiceWorldRunner(
            self.runner_opt, self.world_path, self.max_workers, self,
            opt['is_debug'])  # Replace with base runner
        self.max_agents_for = {
            task: cfg.agents_required
            for task, cfg in self.task_configs.items()
        }
        self.onboard_map = {
            task: cfg.onboarding_name
            for task, cfg in self.task_configs.items()
        }
        self.taskworld_map = {
            task: cfg.task_name
            for task, cfg in self.task_configs.items()
        }
        self.service_reference_id = None
예제 #3
0
    def __init__(self, opt, world_path, max_workers, manager, is_debug=False):
        self._world_module = utils.get_world_module(world_path)
        self.executor = futures.ThreadPoolExecutor(max_workers=max_workers)
        self.debug = is_debug
        self._log("Found world module: {}".format(self._world_module))
        opt["is_debug"] = is_debug
        self.manager = manager
        self.system_done = False
        self.opt = opt
        self.tasks = {}  # task ID to task
        self.initialized = False

        def _is_done_initializing(fut):
            e = fut.exception()
            if e is not None:
                self._log('`module_initialize` returned with error {}'.format(
                    repr(e)))
                if self.debug:
                    raise e
            if fut.result():
                print(fut.result())
            if self.debug:
                print("DEBUG: Call to `module_initialize` has completed...")
            self.initialized = True

        if hasattr(self._world_module, "module_initialize"):
            self._log("Initializing world module...")
            # perform any module intialization steps
            init_fn = self._world_module.module_initialize
            self.init_fut = self.executor.submit(init_fn, opt, manager)
            self.init_fut.add_done_callback(_is_done_initializing)
        else:
            self._log(
                "World module does not have `module initialize` function")
            self.initialized = True
예제 #4
0
 def _parse_config(self, opt):
     """
     Parse config for task.
     """
     self.config = opt['config']
     self.overworld = self.config['overworld']
     self.world_path = self.config['world_path']
     self.world_module = shared_utils.get_world_module(self.world_path)
     self.page_id = self.config['page_id']
     if self.page_id == 1:
         raise RuntimeError(
             'Please configure your own page in order to run this task. '
             'See the docs (https://parl.ai/docs/tutorial_messenger.html) '
             'for more information.')
     self.task_configs = self.config['configs']
     self.max_workers = self.config['max_workers']
     self.opt['task'] = self.config['task_name']
     # Deepcopy the opts so the manager opts aren't changed by the world runner
     self.runner_opt = copy.deepcopy(opt)
     self.world_runner = MessengerWorldRunner(self.runner_opt,
                                              self.world_path,
                                              self.max_workers, self,
                                              opt['is_debug'])
     self.max_agents_for = {
         task: cfg.agents_required
         for task, cfg in self.task_configs.items()
     }
     self.onboard_map = {
         task: cfg.onboarding_name
         for task, cfg in self.task_configs.items()
     }
     self.taskworld_map = {
         task: cfg.task_name
         for task, cfg in self.task_configs.items()
     }
예제 #5
0
 def __init__(self, opt, world_path, max_workers, manager, is_debug=False):
     self._world_module = utils.get_world_module(world_path)
     self.executor = futures.ThreadPoolExecutor(max_workers=max_workers)
     self.debug = is_debug
     self._log("Found world module: {}".format(self._world_module))
     opt["is_debug"] = is_debug
     self.manager = manager
     self.system_done = False
     self.opt = opt
     self.tasks = {}  # task ID to task
예제 #6
0
 def _parse_config(self, opt):
     """Parse config for task."""
     self.config = opt['config']
     self.overworld = self.config['overworld']
     self.world_path = self.config['world_path']
     self.world_module = shared_utils.get_world_module(self.world_path)
     self.max_workers = self.config['max_workers']
     self.task_configs = self.config['configs']
     self.opt['task'] = self.config['task_name']
     self.world_runner = MessengerWorldRunner(opt, self.world_path,
                                              self.max_workers, self,
                                              opt['is_debug'])
     self.max_agents_for = {
         task: cfg.agents_required
         for task, cfg in self.task_configs.items()
     }
     self.onboard_map = {
         task: cfg.onboarding_name
         for task, cfg in self.task_configs.items()
     }
     self.taskworld_map = {
         task: cfg.task_name
         for task, cfg in self.task_configs.items()
     }