I was thinking about implementing support for multiple inputs (and maybe outputs) to pipelines. For example, it would be nice to be able to
@pipeline
def add(a1, a2):
return a1 + a2
i1 = pims.open("img1.tif")
i2 = pims.open("img2.tif")
i12 = add(i1, i2)
Before I start I wanted to ask how to go about it. A few possibilities, decreasing in elegance (in my opinion) but increasing in API compatibility:
- Extend the
Pipeline class (and pipeline decorator)
- Rearrange
__init__ arguments: def __init__(proc_func, *ancestors, propagate_attrs=None). This breaks the API.
- Keep
__init__ arguments in order: def __init__(*args, propagate_attrs=None), where args[-1] is proc_func. This turns propagate_attrs into a keyword-only and proc_func and ancestor into positional arguments but otherwise preserves the API.
- Preserve the API:
def __init__(ancestor, proc_func, propagate_attrs=None, *other_ancestors)
- Some middle ground between the above
- Create a new class (and decorator). Complete freedom since there is no backward-compatibility to think of.
- Something else I did not think about
Which is the preferred way?
I was thinking about implementing support for multiple inputs (and maybe outputs) to pipelines. For example, it would be nice to be able to
Before I start I wanted to ask how to go about it. A few possibilities, decreasing in elegance (in my opinion) but increasing in API compatibility:
Pipelineclass (andpipelinedecorator)__init__arguments:def __init__(proc_func, *ancestors, propagate_attrs=None). This breaks the API.__init__arguments in order:def __init__(*args, propagate_attrs=None), whereargs[-1]isproc_func. This turnspropagate_attrsinto a keyword-only andproc_funcandancestorinto positional arguments but otherwise preserves the API.def __init__(ancestor, proc_func, propagate_attrs=None, *other_ancestors)Which is the preferred way?