Skip to content

Commit

Permalink
fix: schemas list to model list
Browse files Browse the repository at this point in the history
Signed-off-by: ThibaultFy <[email protected]>
  • Loading branch information
ThibaultFy committed Sep 7, 2023
1 parent 127921e commit 4dee597
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions substra/sdk/backends/local/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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]):
Expand Down

0 comments on commit 4dee597

Please sign in to comment.