This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import List | ||
|
||
from canals import Pipeline, component | ||
from sample_components import StringListJoiner | ||
|
||
|
||
@component | ||
class InputMangler: | ||
@component.output_types(mangled_list=List[str]) | ||
def run(self, input_list: List[str]): | ||
input_list.append("extra_item") | ||
return {"mangled_list": input_list} | ||
|
||
|
||
def test_mutable_inputs(): | ||
pipe = Pipeline() | ||
pipe.add_component("mangler1", InputMangler()) | ||
pipe.add_component("mangler2", InputMangler()) | ||
pipe.add_component("concat1", StringListJoiner()) | ||
pipe.add_component("concat2", StringListJoiner()) | ||
pipe.connect("mangler1", "concat1") | ||
pipe.connect("mangler2", "concat2") | ||
|
||
mylist = ["foo", "bar"] | ||
|
||
result = pipe.run(data={"mangler1": {"input_list": mylist}, "mangler2": {"input_list": mylist}}) | ||
assert result["concat1"]["output"] == result["concat1"]["output"] == ["foo", "bar", "extra_item"] |