Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Improve error messages around schema #270

Open
kvnkho opened this issue Nov 24, 2021 · 1 comment
Open

[FEATURE] Improve error messages around schema #270

kvnkho opened this issue Nov 24, 2021 · 1 comment

Comments

@kvnkho
Copy link
Collaborator

kvnkho commented Nov 24, 2021

Is your feature request related to a problem? Please describe.
When creating a transformer, the error message for invalid annotations is currently very vague. The following example:

from typing import List
from fugue import transform
import pandas as pd

def map_phone_to_location(df: List[List]) -> List[List]:
    for row in df:
        row.append(["test"])
    return df

data = pd.DataFrame({"phone": ["(217)-123-4567", "(217)-234-5678", "(407)-123-4567", 
                               "(407)-234-5678", "(510)-123-4567"]})
transform(data, map_phone_to_location, schema="phone:str, new_col:str")

produces an error like:

FugueInterfacelessError: ('<function map_phone_to_location at 0x7fd1894c5b00> is not a valid transformer', TypeError("Input types not valid IndexedOrderedDict([('df', [Other])]) for <function map_phone_to_location at 0x7fd1894c5b00>"))

Describe the solution you'd like

Instead, I think this error should say something like:

"Detected type "List[List]". The valid type annotations are: ...."

@kvnkho
Copy link
Collaborator Author

kvnkho commented Nov 25, 2021

To add to this, missing type annotations also give an unhelpful error:

def clip(df: pd.DataFrame):
    df['value'] = df['value'].clip(1,2)
    return df

Gives:

FugueInterfacelessError: ('<function clip at 0x7fe34365c710> is not a valid transformer', FugueInterfacelessError("* can't be used on cotransformer output schema"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant