hydroflows.workflow.Method#

class hydroflows.workflow.Method[source]#

Bases: ABC

Base method for all methods.

The method class defines the structure of a method in a HydroFlow workflow. It should have a name, input, output and params, and implement a _run and __init__ method.

Methods

check_input_output_paths

Check if input exists and output parent directory exists.

check_output_exists

Check if output files exist.

dryrun

Run method with dummy outputs.

from_kwargs

Create a new method instance from the method name and its initialization arguments.

run

Run the method with input/output checks.

test_method

Run all tests on the method.

to_dict

Return a serialized dictionary representation of the method input, output and params.

to_kwargs

Return flattened keyword-arguments which result in the same method parametrization.

Attributes

dict

Return a dictionary representation of the method input, output and params.

input

Return the input parameters of the method.

name

output

Return the output parameters of the method.

params

Return the additional parameters of the method.

property input: Parameters#

Return the input parameters of the method.

property output: Parameters#

Return the output parameters of the method.

property params: Parameters#

Return the additional parameters of the method.

to_kwargs(mode='json', exclude_defaults=True, posix_path=False, return_refs=False, **kwargs) Dict[str, Any][source]#

Return flattened keyword-arguments which result in the same method parametrization.

property dict: Dict[str, Dict]#

Return a dictionary representation of the method input, output and params.

to_dict(**kwargs) Dict[source]#

Return a serialized dictionary representation of the method input, output and params.

classmethod from_kwargs(method_name: str | None = None, **kwargs) Method[source]#

Create a new method instance from the method name and its initialization arguments.

test_method() None[source]#

Run all tests on the method.

dryrun(input_files: List[Path], missing_file_error: bool = False, touch_output: bool = False) List[Path][source]#

Run method with dummy outputs.

Parameters:
  • input_files (List[Path]) – List of input paths to check, by default None.

  • missing_file_error (bool, optional) – Raise an error if a missing file is encountered, by default False.

Returns:

List of output paths.

Return type:

List[Path]

run(check_output: bool = True) None[source]#

Run the method with input/output checks.

Parameters:

check_output (bool, optional) – Check if output files are created, by default True.

check_input_output_paths(missing_file_error: bool = True) None[source]#

Check if input exists and output parent directory exists.

Parameters:

missing_file_error (bool, optional) – Raise an error if a missing file is encountered, by default True.

check_output_exists()[source]#

Check if output files exist.