hpcflow.app.Rule#

class hpcflow.app.Rule(check_exists=None, check_missing=None, path=None, condition=None, cast=None, doc=None)#

Bases: Rule

Class to represent a testable condition on an element iteration or run.

Exactly one of check_exists, check_missing and condition 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

from_json_like

Make an instance of this class from JSON (or YAML) data.

test

Test if the rule evaluates to true or false for a given run, or element iteration and action combination.

to_dict

Serialize this object as a dictionary.

to_json_like

Serialize this object as an object structure that can be trivially converted to JSON.

Attributes

app

check_exists

If set, this rule checks this attribute exists.

check_missing

If set, this rule checks this attribute does not exist.

path

Where to look up the attribute to check (if not determined by context).

condition

A general condition for this rule to check.

cast

If set, a cast to apply prior to running the general check.

doc

Optional descriptive text.

app = BaseApp(name='hpcFlow', version='0.2.0a180')#
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:
Return type:

bool

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.