def get_list()

in src/vw-serving/src/vw_serving/sagemaker/config/config_helper.py [0:0]


    def get_list(cls, params, key, allowed_list=None):
        """
        Retrieves a list from configuration dictionary and validates if allowed_list is not empty or None.
        Value must either be list or string that is convertible to a list.
        Ex: string: '["xyz", "pqr"]' or ["a", "b"]
        Raises a CustomerKeyError if key is not present in the params dictionary.
        Raises a CustomerValueError if provided value is not a list or cannot be converted to list or
        the values in the list are not in the non-empty allowed_list

        :param params: configuration dictionary
        :param key: key to use for value retrieval
        :param allowed_list: list of allowed values, No validation is performed if allowed_list is empty or None.
        :return: list object

        """
        try:
            raw_value = params[key]
        except KeyError:
            raise CustomerKeyError(cls._format_missing_hyperparameter_error(key))

        if type(raw_value) is list:
            list_val = raw_value
        else:
            try:
                list_val = json.loads(raw_value)
            except ValueError as e:
                raise CustomerValueError("Hyperparameter must be valid json, but found {}:".format(key), e)

            if type(list_val) is not list:
                raise CustomerValueError("Expected list type for hyperparameter: {}, "
                                         "found value: {} of type: {}".format(key, list_val, type(list_val)))
        if allowed_list:
            cls._validate_list(list_val, allowed_list, key)
        return list_val