From bbfa483bdf3797c02c1ec4efadfd0f3162c1a68c Mon Sep 17 00:00:00 2001 From: Hersh Dhillon Date: Tue, 28 Nov 2023 02:37:55 -0500 Subject: [PATCH] Notifying users about incorrect forward headers (#1392) To the existing error message adding 1. What signature failed (input or output) 2. Providing a signature template to the user 3. Added link to the forward decorator in the EvaDB documentation Pointing users to the following documentation https://evadb.readthedocs.io/en/stable/source/reference/ai/custom-ai-function.html#part-1-writing-a-custom-function --- evadb/functions/decorators/utils.py | 36 ++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/evadb/functions/decorators/utils.py b/evadb/functions/decorators/utils.py index b5a9611143..71940dc6b0 100644 --- a/evadb/functions/decorators/utils.py +++ b/evadb/functions/decorators/utils.py @@ -18,6 +18,40 @@ from evadb.functions.abstract.abstract_function import AbstractFunction +def missing_io_signature_helper() -> str: + """Helper function to print the error message when the input/output signature is missing + + Args: + io_type (str, optional): "input" or "output". Defaults to "input". + + Returns: + str: Error message + """ + signature_template = """ + You can define the io signature using the decorator as follows: + @forward( + input_signatures=[ + PandasDataframe( + columns=[], + column_types=[], + column_shapes=[], + ) + ], + output_signatures=[ + PandasDataframe( + columns=[], + column_types=[], + column_shapes=[], + ) + ], + ) + More information on the how to create the forward decorator can be found here: + https://evadb.readthedocs.io/en/stable/source/reference/ai/custom-ai-function.html#part-1-writing-a-custom-function + """ + + return signature_template + + def load_io_from_function_decorators( function: Type[AbstractFunction], is_input=False ) -> List[Type[FunctionIOCatalogEntry]]: @@ -45,7 +79,7 @@ def load_io_from_function_decorators( assert ( io_signature is not None - ), f"Cannot infer io signature from the decorator for {function}." + ), f"Cannot infer {tag_key} signature from the decorator for {function}.\n {missing_io_signature_helper()}" result_list = [] for io in io_signature: