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

Python client stub generator #176

Merged
merged 13 commits into from Dec 4, 2016
Merged

Python client stub generator #176

merged 13 commits into from Dec 4, 2016

Conversation

tvannoy
Copy link
Contributor

@tvannoy tvannoy commented Nov 2, 2016

I've added support for generating python client stubs.

Rather than littering this repo with python files or using the stubgenerator to make a monolithic python file with all of the required classes, I decided to make an independent python client library located at:
https://github.com/tvannoy/jsonrpc_pyclient
https://pypi.python.org/pypi/jsonrpc-pyclient/1.0.1

To use the generated python client stub, one needs to install the above library with "pip install jsonrpc_pyclient". The python library currently supports http and tcp sockets.

I wasn't quite sure how to document the need for the external library, so I mentioned it in the generated python file and in doxygen for the PythonClientStubGenerator.

I'm open to suggestions.

@cinemast
Copy link
Owner

Hi!

Thank you for this contribution. I do like your approach with the external library. I was just wondering if there isn't an already existing python json-rpc implementation that is kind of more standard?

For example this: https://pypi.python.org/pypi/json-rpc

@tvannoy
Copy link
Contributor Author

tvannoy commented Nov 29, 2016

Hi!

I checked out quite a few different python json-rpc libraries when I was developing this PR. I definitely didn't want to reinvent the wheel, but I never really found one that was quite what I wanted. Most of the libraries were tightly coupled to their transport implementations, and those that weren't had other things I didn't like.

https://pypi.python.org/pypi/json-rpc is good, but it seemed like there wasn't a clean way to implement an object-oriented client with it.

My favorite library was https://github.com/gerold-penz/python-jsonrpc, but it doesn't support python 3, and the maintainer has no interest in anyone adding python 3 support. Tinyrpc also doesn't have python 3 support, and isn't actively developed.

https://jsonrpcclient.readthedocs.io looks like it could work.

Ultimately, I just decided that it'd be easiest to make my own library that had an architecture that easily integrated with your stubgen. If you'd like, I can continue looking at other libraries, though, and see if I can contribute to them to add the functionality I need.

Thanks for taking the time to look at my PR!

@cinemast
Copy link
Owner

I see, great that evaluated some frameworks. It is a pitty that they are so badly decoupled.

I would be open to merge the PR as is, if you could do a quick evaluation on https://jsonrpcclient.readthedocs.io and decide that is has major drawbacks over your current solution.

Could you do that? Thank you very much for your efforts.

@tvannoy
Copy link
Contributor Author

tvannoy commented Nov 30, 2016 via email

@tvannoy
Copy link
Contributor Author

tvannoy commented Dec 1, 2016

By itself, I'm able to make jsonrpcclient work with your server, but I couldn't manage to get it to integrate inside another class that I could autogen.

It's architecture is basically such that each transport mechanism (http, etc.) has it's own client (there's an http_client, zeromq_client, etc.); rather than having a general client that "has a" transport, each transport subclasses the general client. I think I prefer the libjson-rpc-cpp's architecture, which my library copied.

For what it's worth, the majority of what I want to do could be done with jsonrpcclient without doing any stub generation, but I kind of like having a unified spec/contract that can be used for a python client and a cpp server.

@cinemast
Copy link
Owner

cinemast commented Dec 1, 2016

Thanks for going the extra mile. I will merge your PR within the next days.

@cinemast cinemast merged commit 1feb600 into cinemast:develop Dec 4, 2016
@tvannoy tvannoy deleted the python-client branch December 6, 2016 18:04
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

Successfully merging this pull request may close these issues.

None yet

2 participants