hpcflow.app.ActionRule#
- class hpcflow.app.ActionRule(rule=None, check_exists=None, check_missing=None, path=None, condition=None, cast=None, doc=None)#
Bases:
ActionRule
Class to represent a rule/condition that must be True if an action is to be included.
- Parameters:
rule (Rule) – The rule to apply.
check_exists (str) – A special rule that is enabled if this named attribute is present.
check_missing (str) – A special rule that is enabled if this named attribute is absent.
path (str) – Where to find the attribute to check.
condition (dict | ConditionLike) – A more complex condition to apply.
cast (str) – The name of a class to cast the attribute to before checking.
doc (str) – Documentation for this rule, if any.
Methods
Make an action rule that checks if a named attribute is present.
Make an action rule that checks if a named attribute is absent.
Make an instance of this class from JSON (or YAML) data.
Test if this rule holds for a particular iteration.
Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
Attributes
The rule to apply.
The action that contains this rule.
The command that is guarded by this rule.
- classmethod check_exists(check_exists)#
Make an action rule that checks if a named attribute is present.
Parameter#
- check_exists:
The path to the attribute to check for.
- Parameters:
check_exists (str) –
- Return type:
- classmethod check_missing(check_missing)#
Make an action rule that checks if a named attribute is absent.
Parameter#
- check_missing:
The path to the attribute to check for.
- Parameters:
check_missing (str) –
- Return type:
- classmethod from_json_like(json_like, shared_data=None)#
Make an instance of this class from JSON (or YAML) data.
- Parameters:
json_like (str | Mapping[str, JSONed] | Sequence[Mapping[str, JSONed]] | None) – The data to deserialise.
shared_data (Mapping[str, ObjectList[JSONable]] | None) – Shared context data.
- Return type:
The deserialised object.
- rule#
The rule to apply.
- test(element_iteration)#
Test if this rule holds for a particular iteration.
Parameter#
- element_iteration:
The iteration to apply this rule to.
- Parameters:
element_iteration (ElementIteration) –
- Return type:
- to_json_like(dct=None, shared_data=None, exclude=(), 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.