Custom coercions no longer working starting in v1.10.0
Checklist
- [x] I have included information about relevant versions
- [ ] I have verified that the issue persists when using the
masterbranch of Faust.- Confirmed issue exists in latest release (1.10.3)
Steps to reproduce
When attempting to upgrade from Faust 1.6.0 I noticed custom coercions defined on my models are no longer being called. I reproduced this in v1.10.0 but did not try any of the 1.9.* versions after 1.9.0.
Steps to reproduce:
using Faust v1.9.0 (works as expected)
>>> from faust import Record
>>> def coercion_handler(input):
... return 'junk'
...
>>> class MyJunkModel(Record, coercions={str: coercion_handler}):
... junk: str
...
>>> x = MyJunkModel(junk=1)
>>> x
<MyJunkModel: junk='junk'>
using Faust v1.10.3 (does not work as expected)
>>> from faust import Record
>>> def coercion_handler(input):
... return 'junk'
...
>>> class MyJunkModel(Record, coercions={str: coercion_handler}):
... junk: str
...
>>> x = MyJunkModel(junk=1)
>>> x
<MyJunkModel: junk=1>
When reproducing in an IDE with a debugger in the coercion handler in v1.10.3 the handler seems as though it is never called.
Versions
- Python version: 3.6.5
- Faust version: 1.10.0/1.10.3
- Operating system: Mac OSX 10.14
- Kafka version: NA
- RocksDB version (if applicable)
Interestingly, if I add coerce=True to the model, the value will be coerced to the type that it was defined with, but it still does not use the custom handler:
>>> class MyOtherJunkModel(Record, coerce=True, coercions={str: coercion_handler}):
... junk: str
...
>>> y = MyOtherJunkModel(junk=1)
>>> y
<MyOtherJunkModel: junk='1'>
Notice that here I passed in int and it has correctly been coerced to str but not using the handler as I would expect.
I hope this feature hasn't been deprecated as I use it heavily and find it to be a really elegant solution for cleaning and transforming some types of data.
I too would like to be able to perform custom coercions - I wasn't using faust prior to v1.10, but I would like to use this for, e.g., UUID standardization at the Record level.
+1