diff --git a/inference_schema/schema_decorators.py b/inference_schema/schema_decorators.py index 719097d..63e7668 100644 --- a/inference_schema/schema_decorators.py +++ b/inference_schema/schema_decorators.py @@ -54,7 +54,7 @@ def decorator_input(user_run, instance, args, kwargs): 'is not in the decorated function.'.format(param_name)) param_position = arg_names.index(param_name) args[param_position] = _deserialize_input_argument(args[param_position], param_type, param_name) - elif param_name not in kwargs.keys() and optional: + elif optional and (param_name not in kwargs.keys() or not kwargs[param_name]): pass else: kwargs[param_name] = _deserialize_input_argument(kwargs[param_name], param_type, param_name) diff --git a/tests/test_pandas_parameter_type.py b/tests/test_pandas_parameter_type.py index 971c4a1..28a4f94 100644 --- a/tests/test_pandas_parameter_type.py +++ b/tests/test_pandas_parameter_type.py @@ -110,6 +110,21 @@ def test_pandas_params_handling_without_params(self, decorated_pandas_func_param assert result[0][0] == "this is a string starting with" assert result[1] == 0 + def test_pandas_params_handling_with_none_params(self, decorated_pandas_func_parameters): + pandas_input_data = { + "columns": [ + "sentence1" + ], + "data": [ + ["this is a string starting with"] + ], + "index": [0] + } + parameters = None + result = decorated_pandas_func_parameters(pandas_input_data, params=parameters) + assert result[0][0] == "this is a string starting with" + assert result[1] == 0 + class TestNestedType(object):