hydroflows.workflow.Rule#
- class hydroflows.workflow.Rule(method: Method, workflow: Workflow, rule_id: str | None = None)[source]#
Bases:
object
Rule class.
A rule is a wrapper around a method to be run in the context of a workflow. The rule is responsible for detecting wildcards and evaluating them based on the workflow wildcards. It creates method instances based on the wildcards and evaluates all input and output paths of the rule. The rule can be run and dryrun.
There is one common rule class to rule all methods.
Methods
Attributes
Return the input paths of the rule per field.
Return a list of all method instances.
Return the number of required method runs.
Return the output paths of the rule per field.
Return a wildcard - fieldname dictionary.
Return the wildcards of the rule per wildcard type.
Return the workflow.
- property wildcards: Dict[str, List]#
Return the wildcards of the rule per wildcard type.
Wildcards are saved for three types, based on whether these “expand” (1:n), “reduce” (n:1) and “repeat” (n:n) the method.
- property wildcard_fields: Dict[str, List]#
Return a wildcard - fieldname dictionary.
Per wildcard it contains all input, output and params field names which have the wildcard.
- run(max_workers=1) None [source]#
Run the rule.
- Parameters:
max_workers (int, optional) – The maximum number of workers to use, by default 1
- dryrun(input_files: List[Path] | None = None, missing_file_error: bool = False) List[Path] [source]#
Dryrun the rule.
- Parameters:
input_files (List[Path], optional) – The input files to use for the dryrun, by default None
missing_file_error (bool, optional) – Whether to raise an error if a file is missing, by default False
- Returns:
The output files of the dryrun.
- Return type:
List[Path]