hydroflows.workflow.Workflow#
- class hydroflows.workflow.Workflow(name='hydroflows', config: Dict | WorkflowConfig | None = None, wildcards: Dict | None = None, root: Path | None = None)[source]#
Bases:
object
Create a workflow instance.
- Parameters:
config (Dict, optional) – The configuration of the workflow, by default None.
wildcards (Dict, optional) – The wildcard keys and values of the workflow, by default None.
Methods
Create a rule based on a method.
Add a rule for method 'name' with keyword-arguments 'kwargs'.
Dryrun the workflow.
Load a workflow from a yaml file.
Get a cross-reference to previously set rule parameters or workflow config.
Plot the rulegraph.
Run the workflow.
Save the workflow to a CWL workflow.
Save the workflow to a snakemake workflow.
Save the workflow to a yaml file.
Attributes
Get the root of the workflow.
- create_rule(method: Method, rule_id: str | None = None) Rule [source]#
Create a rule based on a method.
- create_rule_from_kwargs(method: str, kwargs: Dict[str, str], rule_id: str | None = None) None [source]#
Add a rule for method ‘name’ with keyword-arguments ‘kwargs’.
- get_ref(ref: str) Ref [source]#
Get a cross-reference to previously set rule parameters or workflow config.
- to_snakemake(snakefile: str = 'Snakefile', dryrun: bool = False) None [source]#
Save the workflow to a snakemake workflow.
- Parameters:
snakefile (Path) – The snakefile filename, by default “Snakefile”.
dryrun (bool, optional) – Run the workflow in dryrun mode, by default False.
- to_cwl(cwlfile: Path = None, dryrun: bool = False, touch_inputs: bool = False) None [source]#
Save the workflow to a CWL workflow.
- Parameters:
cwlfile (Path) – Path to the CWL workflow file. CWL files for individual methods will be created in the subfolder <cwlfile>/cwl.
dryrun (bool, optional) – Run the workflow in dryrun mode, by default False
- dryrun(missing_file_error: bool = False) None [source]#
Dryrun the workflow.
- Parameters:
missing_file_error (bool, optional) – Raise an error when a file is missing, by default False.
- plot_rulegraph(filename: str | Path | None = 'rulegraph.svg', plot_rule_attrs=True) Digraph [source]#
Plot the rulegraph.
The rulegraph is a directed graph where the nodes are rules and the edges are dependencies.
The nodes are colored based on the type of rule: Expand rules are colored blue, reduce rules are colored green, and rules with repeat wildcards are colored purple. Result rules are colored red.
- Parameters:
- Returns:
The graphviz Digraph object.
- Return type:
graphviz.Digraph