Skip to content

Create dataset - #8

Merged
xmunoz merged 16 commits into
afeld:masterfrom
timwis:create-dataset
Nov 23, 2015
Merged

xmunoz merged 16 commits into
afeld:masterfrom
timwis:create-dataset

Conversation

@timwis

@timwis timwis commented Nov 19, 2015

Copy link
Copy Markdown
Collaborator

Not ready to merge yet. This is a work in progress. Just opening the pull request to encourage discussion around the implementation. (Update: Ready to merge)

I'm still new to python and would love feedback and suggestions. I figure there's also room to discuss things like columns, and the fact that creating a dataset is actually 3 HTTP requests (create, set public, publish). Here's what I have so far.

Edit: Another thing worth discussing is the fact that this uses the new API, so /resource/asdf-asdf.json is not the correct path (it's /api/views/asdf-asdf.json). I'd make the argument for abstracting the resource in the library and only looking for the 4x4 dataset ID. This way it would be very easy to switch from the old API to the new one, even for reading/GETs. I imagine in order to make this a non-breaking change, we'd have to allow the /resource/xxxx.json usage and just trim it off the string as I've done in this pull request.

@xmunoz

xmunoz commented Nov 19, 2015

Copy link
Copy Markdown
Collaborator

Thanks for your PR. I haven't looked over this super thoroughly yet, but my initial feedback is this: This is amazing! Can you add tests?

@timwis

timwis commented Nov 19, 2015

Copy link
Copy Markdown
Collaborator Author

Definitely. Just ran out of time this morning :P here's what I'm planning to add so far: https://github.com/timwis/sodapy/issues

@xmunoz

xmunoz commented Nov 19, 2015

Copy link
Copy Markdown
Collaborator

Rad! I'm glad someone else wants to take this up, because I'm rather busy these days. Can you also add an issue about updating the readme to describe this new endpoint's usage? I should have more time this weekend to review the code and provide more constructive feedback.

@timwis

timwis commented Nov 19, 2015

Copy link
Copy Markdown
Collaborator Author

Sounds great. I'll try to work on the other items in the meantime

@timwis

timwis commented Nov 21, 2015

Copy link
Copy Markdown
Collaborator Author

So I've added a test for create() but I've gone down a rabbit hole trying to add a request for set_public() to verify the query string parameters are constructed properly. It ended with this diagnosis. I notice your tests for get() don't verify the querystring construction either - perhaps you ran into this issue as well? Any thoughts on using http as the protocol instead of mock?

Comment thread tests/test_soda.py Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requests library drops querystring parameters when the protocol is not http/https. (details)

Comment thread sodapy/__init__.py

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

session.mount() works when passed mock but not when https - for https to work, it needs to be passed https://. I'm not sure why this is, but the documentation suggests this approach fits fine. It required a few changes elsewhere, removing :// from a few string constructors. The alternative to doing that is to inject a :// into the session.mount() call, but I chose not to do that in case, in theory, you wanted to use a longer prefix like http://google.com (which would work with this approach)

@timwis

timwis commented Nov 22, 2015

Copy link
Copy Markdown
Collaborator Author

Okay @xmunoz, this pull request is ready to merge on my end! I've added a good number of comments and explanations alongside the changes. Let me know what you think.

Comment thread sodapy/__init__.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, you're right. Doing stuff like this is silly. I like the idea of only requiring the user to pass the 4x4 code + content-type extension and then building the URLs in the calls depending on which version of the API we are hitting. That's kind of asking a lot from you though, so I'll merge this first and do the cleanup in a separate commit.

@xmunoz

xmunoz commented Nov 22, 2015

Copy link
Copy Markdown
Collaborator

Thanks for all of your work on this! This is really impressive for someone who is just beginning with Python. My comments are minor: Can you delete this at the end of the README.md? 😉 I think that and the whitespace cleanup should just about do it for this PR.

Also, don't worry about updating the other README. It's in rst format, which is the pypi formatting language for the package. I just use pandoc to convert from markdown to rst, so README.md is actually the authoritative one. I'll need to do a couple of things before I build the next version for pypi anyway (v1/v2 url refactor, bump version number, etc).

It's late in Berlin. If you can take care of those two little things, I'll merge in the morning.

@timwis

timwis commented Nov 22, 2015

Copy link
Copy Markdown
Collaborator Author

Thanks for the encouragement! I've implemented those changes. Let me know when you get a chance to update it in pypi as I intend to use it in this project. Danke und guten nacht!

xmunoz added a commit that referenced this pull request Nov 23, 2015
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.

2 participants