azure-sdk-for-python: RecognizedForm is not serializable
- Package Name: azure-ai-formrecognizer
- Package Version: 1.0.0b3
- Operating System: Linux (Azure Durable Functions)
- Python Version: 3.7.7
Describe the bug Using Azure Functions, it is hard to work with Form Recognizer SDK since you can not pass the result of the call to another function.
To Reproduce Steps to reproduce the behavior:
- Use `begin_recognize_custom_forms_from_url()
- Call poller.result() which returns an RecognizedForm object
- Pass the RecognizedForm object to
json.dumps()
or a similar function.
Expected behavior
RecognizedForm
class should be serializable
Additional context
[06/30/2020 15:01:26] Exception: ValueError: activity trigger output must be json serializable ([RecognizedForm(form_type=form-xxxx-xxxx, fields={'naam': FormField(label_data=None, value_data=FieldText(page_number=1, text=Scheepers, bounding_box=[Point(x=979.0, y=541.0), Point(x=1433.0, y=541.0), Point(x=1433.0, y=619.0), Point(x=979.0, y=619.0)]
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (13 by maintainers)
@catalinaperalta , I would suggest you check with @mccoyp if the JsonEncoder is enough to solve the question
The following samples
sample_convert_to_and_from_dict.py
andsample_convert_to_and_from_dict_async.py
have been added to show how the Python Form Recognizer SDK facilitates serialization under the samples folder for both v3.1 and v3.2-beta versions of the SDK.Will close this issue now, please feel free to open new issues with questions or feedback. Thanks!
Very cool! Thank you for explaining and sharing how you’re using the SDK. 😃
Just wanted to call out - the Form Recognizer SDK does support aiohttp, you can find the clients under the
azure.ai.formrecognizer.aio
namespace. And here are some samples you can take a look at.@kristapratico thanks, that works. I would have expected to have something in the class making it JSON serialisable by default, but not sure if this is default behaviour in Python.
Thanks for tagging it as a feature request @lmazuel.