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 #26

Open
matryer opened this issue Nov 19, 2020 · 8 comments
Open

Python client #26

matryer opened this issue Nov 19, 2020 · 8 comments

Comments

@matryer
Copy link
Contributor

matryer commented Nov 19, 2020

We are working on a Python client for Oto.

Can you help?

@sethcenterbar
Copy link

👋
I've got some time this weekend. Are there any more specific requirements or goals for this client?

@matryer
Copy link
Contributor Author

matryer commented Nov 21, 2020

Hey Seth, that'd be great.

We're trying to add type checks to the Python request objects. And maybe return some typed objects that are easy to extract the data from?

@matryer
Copy link
Contributor Author

matryer commented Nov 21, 2020

Here's what we have so far: https://github.com/pacedotdev/oto/blob/master/otohttp/templates/client.py.plush

It works :) But we want to improve the dev experience but adding some type help, and some better docs.

@sethcenterbar
Copy link

Awesome. Going to get started in just a bit and hopefully have something today.

@matryer
Copy link
Contributor Author

matryer commented Nov 21, 2020

Great - maybe it's worth building a little example Python script that talks to the example service in /example?

@sethcenterbar
Copy link

I've added python generation to /example.

Just want to make sure I'm on the right track when it comes to the 'Typing in Python' objective. I'm thinking the struct generation happening in the following code..

# server.go.plush
<%= for (object) in def.Objects { %>
<%= format_comment_text(object.Comment) %>type <%= object.Name %> struct {
	<%= for (field) in object.Fields { %><%= format_comment_text(field.Comment) %><%= field.Name %> <%= if (field.Type.Multiple == true) { %>[]<% } %><%= field.Type.TypeName %> `json:"<%= field.NameLowerCamel %><%= if (field.OmitEmpty) { %>,omitempty<% } %>"`
<% } %>

..should be added to the python client plush as classes instead of structs, with python type hints instead of explicit go types.

@matryer
Copy link
Contributor Author

matryer commented Nov 22, 2020 via email

@sethcenterbar
Copy link

sethcenterbar commented Nov 22, 2020

Yeah I think so. The trouble I have is that I don’t know what the Python code is supposed to look like :) I guess the goal would be so that a) people know what to put in without necessarily consulting the docs, and b) the runtime could even throw an errors if there are unwanted fields. Little touches like this make consuming the SDK easier, which is the ultimate goal. Mat

Unfortunately, python is still going to rely pretty heavily on docstrings to be discoverable, even with type hints.

There are quite a few standards on docstrings in python, but this guide is pretty clear cut. I'm going to start implementing it because I think it's the most readable, but I could also see some pythonistas looking for sphinx style documentation. I guess that could just be another template.

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

No branches or pull requests

2 participants