You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ibis raises a SignatureValidationError when creation of a new op node fails due to an invalid call. This is a user facing error that may result from passing an invalid type or value to a user-facing ibis method.
Currently this error reprs the args to the function in a few places, which is non-ideal:
In non-interactive mode, the repr of an expression can take up a ton of vertical space, and isn't helpful to the user diagnosing the error.
In interactive mode, the repr executes the expression (usually several times) before repring it. This may be both expensive and messes with the formatting of the error.
Ideally our error messages provide hints as to what was expected (type and/or shape), what was received (type and/or shape), but shouldn't need to repr the actual values (except in the case of literal scalars like 1/`"foo"/etc...).
For an example, here's what the user sees when adding an int and string column together:
Non-interactive mode
In [1]: importibisIn [2]: t=ibis.examples.diamonds.fetch()
In [3]: t.price+t.color# invalid addition---------------------------------------------------------------------------SignatureValidationErrorTraceback (mostrecentcalllast)
CellIn[3], line1---->1t.price+t.color# invalid additionFile~/Code/ibis/ibis/expr/types/strings.py:1660, inStringValue.__radd__(self, other)
1621def__radd__(self, other: str|StringValue) ->StringValue:
1622"""Concatenate strings. 1623 1624 Parameters (...) 1658 └────────────────────────┘ 1659 """->1660returnops.StringConcat((other, self)).to_expr()
File~/Code/ibis/ibis/common/bases.py:72, inAbstractMeta.__call__(cls, *args, **kwargs)
52def__call__(cls, *args, **kwargs):
53"""Create a new instance of the class. 54 55 The subclass may override the `__create__` classmethod to change the (...) 70 71 """--->72returncls.__create__(*args, **kwargs)
File~/Code/ibis/ibis/common/grounds.py:119, inAnnotable.__create__(cls, *args, **kwargs)
116 @classmethod117def__create__(cls, *args: Any, **kwargs: Any) ->Self:
118# construct the instance by passing only validated keyword arguments-->119kwargs=cls.__signature__.validate(cls, args, kwargs)
120returnsuper().__create__(**kwargs)
File~/Code/ibis/ibis/common/annotations.py:501, inSignature.validate(self, func, args, kwargs)
498this[name] =result500iferrors:
-->501raiseSignatureValidationError(
502"{call} has failed due to the following errors:{errors}\n\nExpected signature: {sig}",
503sig=self,
504func=func,
505args=args,
506kwargs=kwargs,
507errors=errors,
508 )
510returnthisSignatureValidationError: StringConcat((r0:=DatabaseTable: diamondscaratfloat64cutstringcolorstringclaritystringdepthfloat64tablefloat64priceint64xfloat64yfloat64zfloat64price: r0.price, r0:=DatabaseTable: diamondscaratfloat64cutstringcolorstringclaritystringdepthfloat64tablefloat64priceint64xfloat64yfloat64zfloat64color: r0.color)) hasfailedduetothefollowingerrors:
`arg`: (r0:=DatabaseTable: diamondscaratfloat64cutstringcolorstringclaritystringdepthfloat64tablefloat64priceint64xfloat64yfloat64zfloat64price: r0.price, r0:=DatabaseTable: diamondscaratfloat64cutstringcolorstringclaritystringdepthfloat64tablefloat64priceint64xfloat64yfloat64zfloat64color: r0.color) isnotatupleofcoerciblestoaValue[String, DataShape]
Expectedsignature: StringConcat(arg: tuple[Value[String, DataShape], ...])
Interactive Mode
In [5]: t.price+t.color# invalid addition---------------------------------------------------------------------------SignatureValidationErrorTraceback (mostrecentcalllast)
CellIn[5], line1---->1t.price+t.color# invalid additionFile~/Code/ibis/ibis/expr/types/strings.py:1660, inStringValue.__radd__(self, other)
1621def__radd__(self, other: str|StringValue) ->StringValue:
1622"""Concatenate strings. 1623 1624 Parameters (...) 1658 └────────────────────────┘ 1659 """->1660returnops.StringConcat((other, self)).to_expr()
File~/Code/ibis/ibis/common/bases.py:72, inAbstractMeta.__call__(cls, *args, **kwargs)
52def__call__(cls, *args, **kwargs):
53"""Create a new instance of the class. 54 55 The subclass may override the `__create__` classmethod to change the (...) 70 71 """--->72returncls.__create__(*args, **kwargs)
File~/Code/ibis/ibis/common/grounds.py:119, inAnnotable.__create__(cls, *args, **kwargs)
116 @classmethod117def__create__(cls, *args: Any, **kwargs: Any) ->Self:
118# construct the instance by passing only validated keyword arguments-->119kwargs=cls.__signature__.validate(cls, args, kwargs)
120returnsuper().__create__(**kwargs)
File~/Code/ibis/ibis/common/annotations.py:501, inSignature.validate(self, func, args, kwargs)
498this[name] =result500iferrors:
-->501raiseSignatureValidationError(
502"{call} has failed due to the following errors:{errors}\n\nExpected signature: {sig}",
503sig=self,
504func=func,
505args=args,
506kwargs=kwargs,
507errors=errors,
508 )
510returnthisSignatureValidationError: StringConcat((┏━━━━━━━┓
┃ price ┃
┡━━━━━━━┩
│ int64 │
├───────┤
│ 326 │
│ 326 │
│ 327 │
│ 334 │
│ 335 │
│ 336 │
│ 336 │
│ 337 │
│ 337 │
│ 338 │
│ … │
└───────┘, ┏━━━━━━━━┓
┃ color ┃
┡━━━━━━━━┩
│ string │
├────────┤
│ E │
│ E │
│ E │
│ I │
│ J │
│ J │
│ I │
│ H │
│ E │
│ H │
│ … │
└────────┘)) hasfailedduetothefollowingerrors:
`arg`: (┏━━━━━━━┓
┃ price ┃
┡━━━━━━━┩
│ int64 │
├───────┤
│ 326 │
│ 326 │
│ 327 │
│ 334 │
│ 335 │
│ 336 │
│ 336 │
│ 337 │
│ 337 │
│ 338 │
│ … │
└───────┘, ┏━━━━━━━━┓
┃ color ┃
┡━━━━━━━━┩
│ string │
├────────┤
│ E │
│ E │
│ E │
│ I │
│ J │
│ J │
│ I │
│ H │
│ E │
│ H │
│ … │
└────────┘) isnotatupleofcoerciblestoaValue[String, DataShape]
Expectedsignature: StringConcat(arg: tuple[Value[String, DataShape], ...])
The text was updated successfully, but these errors were encountered:
Ibis raises a
SignatureValidationError
when creation of a new op node fails due to an invalid call. This is a user facing error that may result from passing an invalid type or value to a user-facing ibis method.Currently this error reprs the args to the function in a few places, which is non-ideal:
Ideally our error messages provide hints as to what was expected (type and/or shape), what was received (type and/or shape), but shouldn't need to repr the actual values (except in the case of literal scalars like
1
/`"foo"/etc...).For an example, here's what the user sees when adding an int and string column together:
Non-interactive mode
Interactive Mode
The text was updated successfully, but these errors were encountered: