Filter rules¶
Filter nodes based on a set of rules.
Classes:
| Name | Description |
|---|---|
BinaryOperator |
Operators used for filtering nodes, taking two arguments. |
FilterRule |
Filter an object based on attribute named 'id' and apply the operator with the value. |
FilterRuleEncoder |
JSON encoder for FilterRule objects. |
UnaryOperator |
Operators used for filtering nodes, taking no argument. |
Functions:
| Name | Description |
|---|---|
dict_to_rule |
JSON decoder for FilterRule objects. |
BinaryOperator
¶
FilterRule
¶
FilterRule(
enable: bool,
name: str,
id: str,
operator: BinaryOperator | UnaryOperator,
value: str | int | float | bool | None = None,
)
Filter an object based on attribute named 'id' and apply the operator with the value.
Attributes:
| Name | Type | Description |
|---|---|---|
enable |
bool
|
Enable or disable the rule. |
id |
str
|
attribute to apply the filter on. |
name |
str
|
Human readable string describing the attribute. |
operator |
BinaryOperator | UnaryOperator
|
Operator used for filtering. |
value |
str | int | float | bool | None
|
Comparison value for the filter (if operator is not UnaryOperator). |
FilterRuleEncoder
¶
UnaryOperator
¶
Bases: Enum
Operators used for filtering nodes, taking no argument.
Attributes:
| Name | Type | Description |
|---|---|---|
NOT_PRESENT |
Attribute is not present (attribute value == 0). |
|
PRESENT |
Attribute is present (attribute value >= 1). |
dict_to_rule
¶
dict_to_rule(data: dict) -> FilterRule
JSON decoder for FilterRule objects.
Source code in src/slurm_viewer/data/filter_rules.py
Unit test for the filter rules class.
Functions:
| Name | Description |
|---|---|
test_binary_rules |
Test binary rules |
test_unary_rules |
Test unary rules |
test_binary_rules
¶
Test binary rules
Source code in tests/test_rules.py
test_unary_rules
¶
Test unary rules