def load_vars()

in src/vw-serving/src/vw_serving/serve.py [0:0]


    def load_vars(self):
        """Load env and command line vars.

        This method has to be copied because options run from brazil are also passed to Gunicorn, such as
        '--resource' or '-r' which is required for local training and serving. This failed the parser, which was
        using parse_args(). Copied and modified from superclass.

        See: https://code.amazon.com/packages/Gunicorn/blobs/5ea7b077710253db3ed6676525090ec04c05e4b8/--/gunicorn/app/base.py#L137 # noqa: E501
        """

        def check_unknown_args(args):
            """Check arguments Gunicorn is not aware of, and remove the argument names
             and values the application is aware of. Fail if there are any arguments remaining.

            :param args: Remainder arguments from Gunicorn argparser
            """
            unrecognized_args = {arg for arg in args if arg.startswith("-") and arg not in KNOWN_CLI_ARGS}
            if unrecognized_args:
                raise AlgorithmError("Unrecognized variables used: {}".format(", ".join(unrecognized_args)))

        def set_config(args, cfg):
            for k, v in vars(args).items():
                if v is None:
                    continue
                if k == "args":
                    continue
                cfg.set(k.lower(), v)

        parser = self.cfg.parser()
        parsed_args = parser.parse_known_args()
        known_args = parsed_args[0]
        unknown_args = parsed_args[1]

        check_unknown_args(unknown_args)

        env_vars = self.cfg.get_cmd_args_from_env()
        if env_vars:
            env_args = parser.parse_args(env_vars)
            set_config(env_args, self.cfg)

        # Lastly, update the configuration with any command line
        # settings. Note that identical env vars will not be updated.
        set_config(known_args, self.cfg)