in lib/metric-config-parser/metric_config_parser/parameter.py [0:0]
def validate(self) -> "ParameterDefinition":
"""
Validates that branch related configuration is correct.
It should not run on every instance of ParameterDefinition object.
Outcome parameters containing defaults would not always adhere to
the rules defined here.
"""
if self.distinct_by_branch and not (
isinstance(self.value, dict) or isinstance(self.default, dict)
):
error_msg = (
f"Parameter {self.name} configured "
"to be distinct by branch, a mapping expected in the following format: "
'for values: value.branch_1 = "1"'
'and defaults: default.branch_1 = "1"'
"See https://experimenter.info/jetstream/outcomes#parameterizing-outcomes for more information" # noqa: E501
)
raise InvalidConfigurationException(error_msg)
elif not self.distinct_by_branch and not (
isinstance(self.value, str) or isinstance(self.default, str)
):
error_msg = (
f"Parameter {self.name} configured "
"to not be distinct by branch, but wrong value type provided. "
"Expected format: "
f'value = "param_value", provided: {self.value}'
f'default = "", provided: {self.default}'
"See https://experimenter.info/jetstream/outcomes#parameterizing-outcomes for more information" # noqa: E501
)
raise InvalidConfigurationException(error_msg)
return self