coursera / courier

Data interchange for the modern web + mobile stack.
http://coursera.github.io/courier/
Apache License 2.0
98 stars 24 forks source link

WIP Py3 bindings #51

Open eboto opened 7 years ago

eboto commented 7 years ago

WORK IN PROGRESS DO NOT MERGE

Discussion here

Python3 Courier Data Binding Generator

Courier bindings for Python 3 (tested against Python 3.6)

Features missing in action

Mainline Courier features that are not yet supported, but will be by the time this thing is ready for submit:

Additional tasks before merging to courier master:

Additional desirable tasks for later:

Pythonic API Questions

Notes from interviews with a real python dev:

eboto commented 7 years ago

Identified and patched a bug in array handling here https://github.com/dfxmachina/vision/pull/103#pullrequestreview-41849394

Gotta incorporate that into this PR

sim0nsays commented 7 years ago

Currently, python bindings don't support required fields that have a default value. Adding a required field should be a backward-compatible change, meaning json records with no field set should be parsed into a valid python object. Right now, bindings will fail to validate such json against the generated AVRO schema.

eboto commented 7 years ago

Validation of unions is broken.

This is because avro deserializes unions into python dicts with a different expected shape than the shape that courier deserializes them into. For example: given union[string], avro would successfully validate "1", which is not a valid representation of a courier union. Likewise, avro would fail to validate {"string": "1"}, which is the valid representation of a courier union.

We will have to either not validate unions, or bring legit validation into the python bindings.

sim0nsays commented 7 years ago

Another feature request: would be really great for the objects to have copy method similar to scala bindings. It would accept **args and produce a copy of the target instance with fields replaced by the name fields in the arguments.

roni-instr commented 6 years ago

Bug report: double quotes in the comment result in an invalid schema.

Description:

Request.courier had the comments like:

/** Expected to be in the "file://" format. */

After generating courier bindings Parameters.py:

# ipython
In [1]: from Request import Request
Exception: Error parsing schema from JSON: '{"type":"record",
....
Error message: JSONDecodeError("Expecting ',' delimiter: line 1 column 3096 (char 3095)",).

No error if"file://" is replaced with 'file://'.

ryfeus commented 5 years ago

@eboto I was looking into python bindings for courier and found this PR thread. I would like to help with this PR to prepare it for master. Are there any tasks which could help this branch?

Thanks.