Skip to content

Commit

Permalink
Update the signature of the __rshift__ for the pipeline and expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinitto committed Feb 8, 2023
1 parent ba70c89 commit 2bb8126
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions funml/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ def __init__(self):
self._queue: List[Expression] = []
self._is_terminated = False

def __rshift__(self, nxt: Union["Expression", Callable, "Pipeline"]):
def __rshift__(
self, nxt: Union["Expression", Callable, "Pipeline"]
) -> Union["Pipeline", Any]:
"""Uses `>>` to append the nxt expression, callable, pipeline to this pipeline.
Args:
nxt: the next expression, pipeline, or callable to apply after the current one.
Returns:
the updated pipeline or the value when the pipeline is executed in case `nxt` is of
type `ExecutionExpression`
Raises:
ValueError: when the pipeline is already terminated with ml.execute() in its queue.
"""
Expand Down Expand Up @@ -183,7 +189,9 @@ def __call__(self, *args: Any, **kwargs: Any) -> Any:
"""
return self._f(*args, **kwargs)

def __rshift__(self, nxt: Union["Expression", "Pipeline", Callable]) -> "Pipeline":
def __rshift__(
self, nxt: Union["Expression", "Pipeline", Callable]
) -> Union["Pipeline", Any]:
"""This makes piping using the '>>' symbol possible.
Combines with the given `nxt` expression or pipeline to produce a new pipeline
Expand All @@ -193,7 +201,8 @@ def __rshift__(self, nxt: Union["Expression", "Pipeline", Callable]) -> "Pipelin
nxt: the next expression, pipeline, or callable to apply after the current one.
Returns:
a new pipeline where the first expression is the current expression followed by `nxt`
a new pipeline where the first expression is the current expression followed by `nxt`
or returns the value when the pipeline is executed in case `nxt` is of type `ExecutionExpression`
"""
new_pipeline = Pipeline()
new_pipeline >> self >> nxt
Expand Down

0 comments on commit 2bb8126

Please sign in to comment.