8000 feat: Fix find_component_inputs, update unit tests by vblagoje · Pull Request #162 · deepset-ai/canals · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

feat: Fix find_component_inputs, update unit tests #162

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion canals/component/descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def find_component_inputs(component: Any) -> Dict[str, Dict[str, Any]]:
)

return {
name: {"type": socket.type, "is_optional": socket.is_optional}
name: {"type": socket.type, "is_mandatory": socket.is_mandatory, "is_variadic": socket.is_variadic}
for name, socket in component.__canals_input__.items()
}

Expand Down
16 changes: 8 additions & 8 deletions test/component/test_component.py
5337
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def run(self, value: int):
return {"value": 1}

comp = MockComponent()
assert find_component_inputs(comp) == {"value": {"is_optional": False, "type": int}}
assert find_component_inputs(comp) == {"value": {"is_mandatory": True, "is_variadic": False, "type": int}}


def test_inputs_method_multiple_inputs():
Expand All @@ -195,8 +195,8 @@ def run(self, value1: int, value2: str):

comp = MockComponent()
assert find_component_inputs(comp) == {
"value1": {"is_optional": False, "type": int},
"value2": {"is_optional": False, "type": str},
"value1": {"is_mandatory": True, "is_variadic": False, "type": int},
"value2": {"is_mandatory": True, "is_variadic": False, "type": str},
}


Expand All @@ -208,8 +208,8 @@ def run(self, value1: int, value2: Optional[str]):

comp = MockComponent()
assert find_component_inputs(comp) == {
"value1": {"is_optional": False, "type": int},
"value2": {"is_optional": True, "type": typing.Optional[str]},
"value1": {"is_mandatory": True, "is_variadic": False, "type": int},
"value2": {"is_mandatory": True, "is_variadic": False, "type": typing.Optional[str]},
}


Expand All @@ -223,7 +223,7 @@ def run(self, *args):
return {"value": 1}

comp = MockComponent()
assert find_component_inputs(comp) == {"value": {"is_optional": False, "type": typing.Any}}
assert find_component_inputs(comp) == {"value": {"is_mandatory": True, "is_variadic": False, "type": typing.Any}}


def test_inputs_method_variadic_keyword_positional_args():
Expand All @@ -236,7 +236,7 @@ def run(self, **kwargs):
return {"value": 1}

comp = MockComponent()
assert find_component_inputs(comp) == {"value": {"is_optional": False, "type": typing.Any}}
assert find_component_inputs(comp) == {"value": {"is_mandatory": True, "is_variadic": False, "type": typing.Any}}


def test_inputs_dynamic_from_init():
Expand All @@ -249,7 +249,7 @@ def run(self, value: int, **kwargs):
return {"value": 1}

comp = MockComponent()
assert find_component_inputs(comp) == {"value": {"is_optional": False, "type": int}}
assert find_component_inputs(comp) == {"value": {"is_mandatory": True, "is_variadic": False, "type": int}}


def test_outputs_method_no_outputs():
Expand Down
0