deepset-ai / canals

A component orchestration engine
https://deepset-ai.github.io/canals/
Apache License 2.0
27 stars 2 forks source link

fix: change `is_optional` with `has_default` #155

Closed ZanSara closed 10 months ago

ZanSara commented 10 months ago

In preparation for: https://github.com/deepset-ai/canals/issues/105


This PR changes InputSocket.is_optional into InputSocket.has_default. This change affects both the semantic of the field and the behavior of Pipeline.

Optional is no more used to signal that the respective inputs are not to be waited for. Now the way to mark inputs as "not to be waited for" is to give them a default value, irrespective of their type.

In short: before, a component that declared:

def run(self, value: Optional[int])

was signaling the Pipeline that value is not to be waited for. Now the way to send the same signal to Pipeline is:

def run(self, value: int = 100)

where 100 could be any value.


Note: this breaks a lot of tests. Fixing this implies modifications in the run() method that will be addressed in separate PRs.