hpcflow.sdk.core.rule.Rule#
- class hpcflow.sdk.core.rule.Rule(check_exists=None, check_missing=None, path=None, condition=None, cast=None, doc=None)#
Bases:
JSONLike
Class to represent a testable condition on an element iteration or run.
Exactly one of
check_exists
,check_missing
andcondition
must be provided.- Parameters:
check_exists (str) – If set, check this attribute exists.
check_missing (str) – If set, check this attribute does not exist.
path (str) – Where to look up the attribute to check. If not specified, determined by context.
condition (ConditionLike) – A general condition to check (or kwargs used to generate one).
cast (str) – If set, a cast to apply prior to running the general check.
doc (str) – Optional descriptive text.
Methods
Make an instance of this class from JSON (or YAML) data.
Test if the rule evaluates to true or false for a given run, or element iteration and action combination.
Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
Attributes
If set, this rule checks this attribute exists.
If set, this rule checks this attribute does not exist.
Where to look up the attribute to check (if not determined by context).
A general condition for this rule to check.
If set, a cast to apply prior to running the general check.
Optional descriptive text.
- cast#
If set, a cast to apply prior to running the general check.
- check_exists#
If set, this rule checks this attribute exists.
- check_missing#
If set, this rule checks this attribute does not exist.
- condition#
A general condition for this rule to check.
- doc#
Optional descriptive text.
- classmethod from_json_like(json_like, shared_data=None)#
Make an instance of this class from JSON (or YAML) data.
- Parameters:
json_like (Union[Dict, List]) – The data to deserialise.
shared_data (Optional[Dict[str, ObjectList]]) – Shared context data.
- Return type:
The deserialised object.
- path#
Where to look up the attribute to check (if not determined by context).
- test(element_like, action=None)#
Test if the rule evaluates to true or false for a given run, or element iteration and action combination.
- Parameters:
element_like (ElementIteration | ElementActionRun) –
action (Action | None) –
- Return type:
- to_dict()#
Serialize this object as a dictionary.
- to_json_like(dct=None, shared_data=None, exclude=None, path=None)#
Serialize this object as an object structure that can be trivially converted to JSON. Note that YAML can also be produced from the result of this method; it just requires a different final serialization step.