Skip to content

Commit

Permalink
Notifying users about incorrect forward headers (georgia-tech-db#1392)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hershd23 authored Nov 28, 2023
1 parent 334c8b1 commit bbfa483
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion evadb/functions/decorators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[<List of cols>],
column_types=[<List of col types>],
column_shapes=[<List of col shapes>],
)
],
output_signatures=[
PandasDataframe(
columns=[<List of cols>],
column_types=[<List of col types>],
column_shapes=[<List of col 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]]:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit bbfa483

Please sign in to comment.