From 4dee5974a773622dc082566826714e4699a9203d Mon Sep 17 00:00:00 2001 From: ThibaultFy <50656860+ThibaultFy@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:33:21 +0200 Subject: [PATCH] fix: schemas list to model list Signed-off-by: ThibaultFy <50656860+ThibaultFy@users.noreply.github.com> --- substra/sdk/backends/local/backend.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/substra/sdk/backends/local/backend.py b/substra/sdk/backends/local/backend.py index 6f6f4ad3..48988de5 100644 --- a/substra/sdk/backends/local/backend.py +++ b/substra/sdk/backends/local/backend.py @@ -299,8 +299,8 @@ def _add_function(self, key, spec, spec_options=None): "storage_address": function_description_path, }, metadata=spec.metadata if spec.metadata else dict(), - inputs=_schemas_list_to_models_list(spec.inputs, models.FunctionInput) or [], - outputs=_schemas_list_to_models_list(spec.outputs, models.FunctionOutput) or [], + inputs=_schemas_list_to_models_list(spec.inputs, models.FunctionInput), + outputs=_schemas_list_to_models_list(spec.outputs, models.FunctionOutput), ) return self._db.add(function) @@ -602,7 +602,10 @@ def _output_from_spec(outputs: Dict[str, schemas.ComputeTaskOutputSpec]) -> Dict def _schemas_list_to_models_list(inputs: Any, model: Any) -> Any: - return [model.model_validate(input_schema.model_dump()) for input_schema in inputs] + if inputs: + return [model.model_validate(input_schema.model_dump()) for input_schema in inputs] + else: + return [] def _warn_on_transient_outputs(outputs: typing.Dict[str, schemas.ComputeTaskOutputSpec]):