refactor: Add input validation for None values in Component class
This commit is contained in:
parent
383229db73
commit
b99ff9f88e
1 changed files with 4 additions and 0 deletions
|
|
@ -66,6 +66,8 @@ class Component(CustomComponent):
|
||||||
def map_inputs(self, inputs: List[InputTypes]):
|
def map_inputs(self, inputs: List[InputTypes]):
|
||||||
self.inputs = inputs
|
self.inputs = inputs
|
||||||
for input_ in inputs:
|
for input_ in inputs:
|
||||||
|
if input_.name is None:
|
||||||
|
raise ValueError("Input name cannot be None.")
|
||||||
self._inputs[input_.name] = input_
|
self._inputs[input_.name] = input_
|
||||||
|
|
||||||
def validate(self, params: dict):
|
def validate(self, params: dict):
|
||||||
|
|
@ -112,6 +114,8 @@ class Component(CustomComponent):
|
||||||
# Build the output if it's connected to some other vertex
|
# Build the output if it's connected to some other vertex
|
||||||
# or if it's not connected to any vertex
|
# or if it's not connected to any vertex
|
||||||
if not vertex.outgoing_edges or output.name in vertex.edges_source_names:
|
if not vertex.outgoing_edges or output.name in vertex.edges_source_names:
|
||||||
|
if output.method is None:
|
||||||
|
raise ValueError(f"Output {output.name} does not have a method defined.")
|
||||||
method: Callable = getattr(self, output.method)
|
method: Callable = getattr(self, output.method)
|
||||||
if output.cache and output.value != UNDEFINED:
|
if output.cache and output.value != UNDEFINED:
|
||||||
_results[output.name] = output.value
|
_results[output.name] = output.value
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue