Skip to content

sift_py.rule.config

CLASS DESCRIPTION
RuleConfig

Defines a rule to be used during ingestion. If a rule's expression validates to try, then

RuleAction
RuleActionCreateDataReviewAnnotation

Action to create a data-review annotation when a rule evaluates to a truthy value.

RuleActionCreatePhaseAnnotation

Action to create a phase annotation when a rule evaluates to a truthy value.

RuleActionKind
RuleActionAnnotationKind
RuleActionKindStrRep
ExpressionChannelReference

channel_reference: The channel reference (e.g. '$1') used in the expression.

ExpressionChannelReferenceChannelConfig

channel_reference: The channel reference (e.g. '$1') used in the expression.

RuleConfig

RuleConfig(
    name: str,
    channel_references: List[
        Union[
            ExpressionChannelReference,
            ExpressionChannelReferenceChannelConfig,
        ]
    ],
    description: str = "",
    expression: str = "",
    action: Optional[RuleAction] = None,
    rule_client_key: Optional[str] = None,
    asset_names: Optional[List[str]] = None,
    tag_names: Optional[List[str]] = None,
    sub_expressions: Dict[str, Any] = {},
    contextual_channels: Optional[List[str]] = None,
    is_external: bool = False,
    is_live_evaluation_enabled: bool = False,
)

Bases: AsJson

Defines a rule to be used during ingestion. If a rule's expression validates to try, then a specific action will take place as specified by the kind attribute.

  • name: Name of the rule.
  • description: Description of the rule.
  • expression: A CEL string expression that executes the action when evaluated to a truthy value.
  • action: The action to execute if the result of an expression evaluates to a truthy value.
  • channel_references: Reference to channel. If an expression is "$1 < 10", then "$1" is the reference and thus should the key in the dict.
  • rule_client_key: User defined unique string that uniquely identifies this rule.
  • asset_names: A list of asset names that this rule should be applied to. ONLY VALID if defining rules outside of a telemetry config.
  • tag_names: A list of asset tags that this rule should be applied to. ONLY VALID if defining rules outside of a telemetry config.
  • contextual_channels: A list of channel names that provide context but aren't directly used in the expression.
  • is_external: If this is an external rule.
  • is_live_evaluation_enabled: If set to True then this rule will be evaluated on live data, otherwise live rule evaluation will be disabled. This rule can still be used, however, in report generation.
METHOD DESCRIPTION
as_json

Produces the appropriate JSON structure that's suitable for the Rules API.

interpolate_sub_expressions
ATTRIBUTE DESCRIPTION
channel_references

TYPE: List[ExpressionChannelReference]

contextual_channels

TYPE: List[str]

name

TYPE: str

asset_names

TYPE: List[str]

tag_names

TYPE: List[str]

action

TYPE: Optional[RuleAction]

rule_client_key

TYPE: Optional[str]

description

TYPE: str

expression

TYPE: str

is_external

TYPE: bool

is_live_evaluation_enabled

TYPE: bool

channel_references instance-attribute

channel_references: List[ExpressionChannelReference] = (
    _channel_references_from_dicts(channel_references)
)

contextual_channels instance-attribute

contextual_channels: List[str] = contextual_channels or []

name instance-attribute

name: str = name

asset_names instance-attribute

asset_names: List[str] = asset_names or []

tag_names instance-attribute

tag_names: List[str] = tag_names or []

action instance-attribute

action: Optional[RuleAction] = action

rule_client_key instance-attribute

rule_client_key: Optional[str] = rule_client_key

description instance-attribute

description: str = description

expression instance-attribute

expression: str = (
    self.__class__.interpolate_sub_expressions(
        expression, sub_expressions
    )
)

is_external instance-attribute

is_external: bool = is_external

is_live_evaluation_enabled instance-attribute

is_live_evaluation_enabled: bool = (
    is_live_evaluation_enabled
)

as_json

as_json() -> Any

Produces the appropriate JSON structure that's suitable for the Rules API.

interpolate_sub_expressions staticmethod

interpolate_sub_expressions(
    expression: str,
    sub_expressions: Optional[Dict[str, str]],
) -> str

RuleAction

Bases: ABC

METHOD DESCRIPTION
kind
ATTRIBUTE DESCRIPTION
tags

TYPE: Optional[List[str]]

tags instance-attribute

tags: Optional[List[str]]

kind abstractmethod

kind() -> RuleActionKind

RuleActionCreateDataReviewAnnotation

RuleActionCreateDataReviewAnnotation(
    assignee: Optional[str] = None,
    tags: Optional[List[str]] = None,
)

Bases: RuleAction

Action to create a data-review annotation when a rule evaluates to a truthy value.

  • tags: List of tag names to associate with the newly created data-review annotation.
  • assignee: Email of user in organization to assign the newly created data-review annotation.
METHOD DESCRIPTION
kind
ATTRIBUTE DESCRIPTION
assignee

TYPE: Optional[str]

tags

TYPE: Optional[List[str]]

assignee instance-attribute

assignee: Optional[str] = assignee

tags instance-attribute

tags: Optional[List[str]] = tags

kind

kind() -> RuleActionKind

RuleActionCreatePhaseAnnotation

RuleActionCreatePhaseAnnotation(
    tags: Optional[List[str]] = None,
)

Bases: RuleAction

Action to create a phase annotation when a rule evaluates to a truthy value.

  • tags: List of tag names to associate with the newly created data-review annotation.
METHOD DESCRIPTION
kind
ATTRIBUTE DESCRIPTION
tags

TYPE: Optional[List[str]]

tags instance-attribute

tags: Optional[List[str]] = tags

kind

kind() -> RuleActionKind

RuleActionKind

Bases: Enum

METHOD DESCRIPTION
from_str
ATTRIBUTE DESCRIPTION
NOTIFICATION

ANNOTATION

NOTIFICATION class-attribute instance-attribute

NOTIFICATION = ActionKind.NOTIFICATION

ANNOTATION class-attribute instance-attribute

ANNOTATION = ActionKind.ANNOTATION

from_str classmethod

from_str(val: str) -> Optional['RuleActionKind']

RuleActionAnnotationKind

Bases: Enum

METHOD DESCRIPTION
from_annotation_type
from_str
ATTRIBUTE DESCRIPTION
REVIEW

PHASE

REVIEW class-attribute instance-attribute

REVIEW = 'review'

PHASE class-attribute instance-attribute

PHASE = 'phase'

from_annotation_type classmethod

from_annotation_type(
    annotation_type: AnnotationType,
) -> "RuleActionAnnotationKind"

from_str classmethod

from_str(val: str) -> 'RuleActionAnnotationKind'

RuleActionKindStrRep

Bases: Enum

ATTRIBUTE DESCRIPTION
NOTIFICATION

ANNOTATION

NOTIFICATION class-attribute instance-attribute

NOTIFICATION = 'notification'

ANNOTATION class-attribute instance-attribute

ANNOTATION = 'annotation'

ExpressionChannelReference

Bases: TypedDict

channel_reference: The channel reference (e.g. '$1') used in the expression. channel_identifier: The channel name.

ATTRIBUTE DESCRIPTION
channel_reference

TYPE: str

channel_identifier

TYPE: str

channel_reference instance-attribute

channel_reference: str

channel_identifier instance-attribute

channel_identifier: str

ExpressionChannelReferenceChannelConfig

Bases: TypedDict

channel_reference: The channel reference (e.g. '$1') used in the expression. channel_config: Instance of sift_py.ingestion.channel.ChannelConfig.

ATTRIBUTE DESCRIPTION
channel_reference

TYPE: str

channel_config

TYPE: ChannelConfig

channel_reference instance-attribute

channel_reference: str

channel_config instance-attribute

channel_config: ChannelConfig