parser_time_aggregation_rule
Module for ParserTimeAggregationRule class
!!! classes ParserTimeAggregationRule
ParserTimeAggregationRule (IParserRuleBase)
Class for creating a TimeAggregationRuleData
Source code in parsers/parser_time_aggregation_rule.py
class ParserTimeAggregationRule(IParserRuleBase):
"""Class for creating a TimeAggregationRuleData"""
@property
def rule_type_name(self) -> str:
"""Type name for the rule"""
return "time_aggregation_rule"
def parse_dict(self, dictionary: Dict[str, Any], logger: ILogger) -> IRuleData:
"""Parses the provided dictionary to a IRuleData
Args:
dictionary (Dict[str, Any]): Dictionary holding the values
for making the rule
Returns:
RuleBase: Rule based on the provided data
"""
# get elements
name: str = get_dict_element("name", dictionary)
description: str = get_dict_element("description", dictionary, False)
input_variable_name: str = get_dict_element("input_variable", dictionary)
operation: str = get_dict_element("operation", dictionary)
time_scale: str = get_dict_element("time_scale", dictionary)
output_variable_name: str = get_dict_element("output_variable", dictionary)
operation_value, percentile_value = parse_operation_values(operation)
rule_data = TimeAggregationRuleData(name, operation_value, input_variable_name)
rule_data.percentile_value = percentile_value
rule_data.time_scale = time_scale
rule_data.output_variable = output_variable_name
rule_data.description = description
return rule_data
rule_type_name: str
property
readonly
Type name for the rule
parse_dict(self, dictionary, logger)
Parses the provided dictionary to a IRuleData
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dictionary |
Dict[str, Any] |
Dictionary holding the values for making the rule |
required |
Returns:
Type | Description |
---|---|
RuleBase |
Rule based on the provided data |
Source code in parsers/parser_time_aggregation_rule.py
def parse_dict(self, dictionary: Dict[str, Any], logger: ILogger) -> IRuleData:
"""Parses the provided dictionary to a IRuleData
Args:
dictionary (Dict[str, Any]): Dictionary holding the values
for making the rule
Returns:
RuleBase: Rule based on the provided data
"""
# get elements
name: str = get_dict_element("name", dictionary)
description: str = get_dict_element("description", dictionary, False)
input_variable_name: str = get_dict_element("input_variable", dictionary)
operation: str = get_dict_element("operation", dictionary)
time_scale: str = get_dict_element("time_scale", dictionary)
output_variable_name: str = get_dict_element("output_variable", dictionary)
operation_value, percentile_value = parse_operation_values(operation)
rule_data = TimeAggregationRuleData(name, operation_value, input_variable_name)
rule_data.percentile_value = percentile_value
rule_data.time_scale = time_scale
rule_data.output_variable = output_variable_name
rule_data.description = description
return rule_data