def parse_args(self, args=None, namespace=None, print_args=True): """ Parse the provided arguments and returns a dictionary of the ``args``. We specifically remove items with ``None`` as values in order to support the style ``opt.get(key, default)``, which would otherwise return ``None``. """ self.add_extra_args(args) self.args = super().parse_args(args=args) self._process_args_to_opts(args) if print_args: self.print_args() if GIT_AVAILABLE: print_git_commit() print_announcements(self.opt) logging.set_log_level(self.opt.get('loglevel', 'info').upper()) return self.opt
def parse_args(self, args=None, namespace=None, **kwargs): """ Parse the provided arguments and returns a dictionary of the ``args``. We specifically remove items with ``None`` as values in order to support the style ``opt.get(key, default)``, which would otherwise return ``None``. """ if 'print_args' in kwargs: logging.error( "You gave the print_args flag to parser.parse_args, but this is " "no longer supported. Use opt.log() to print the arguments") del kwargs['print_args'] self.add_extra_args(args) self.args = super().parse_args(args=args) self._process_args_to_opts(args) print_announcements(self.opt) logging.set_log_level(self.opt.get('loglevel', 'info').upper()) assert '_subparser' not in self.opt return self.opt
def _run_from_parser_and_opt(cls, opt: Opt, parser: ParlaiParser): logging.set_log_level(opt.get('loglevel', 'info').upper()) script = cls(opt) script.parser = parser return script.run()