-
Notifications
You must be signed in to change notification settings - Fork 8
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
allow for passing directly the python dict string as response body #59
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please comment on how this plays with the current CDSAPI.py2ju helper? Should the helper be deprecated?
The current usage of the Both calls will dispatch to Effectively yes, |
A deprecation warning is a good idea. We should update the README with the new recommended method, which is a simple copy/paste of the Python string. The README could also teach users that |
…g to the `py2ju` method.
README.md
Outdated
will do the rest. | ||
Python dictionaries can be valid JSON strings, and the CDS requests builder is kind enough to make it so, (make sure the request string does not contain single quotes, but only double quotes) | ||
|
||
Therefore simply calling `JSON.parse(request)` will return a valid Julia dictionary. This is done for you automatically as the call above will be translated into `CDSAPI.retrieve(dataset, JSON.parse(request), "download.nc")`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that we should always recommend the method with string for end-users, and leave this technical detail about dicts for developers as comments in the source code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes agree, I'll change accordingly.
I've updated the |
Co-authored-by: Júlio Hoffimann <[email protected]>
I've refactored the tests to simplify maintenance, and removed the testset related to py2ju, which now redirects to a new The tests are failing due to an undefined |
That's weird, The endpoint line got clobbered somewhere. Maybe while moving from one pr to the other... |
The tests are now failing due to changes related to py2ju. Appreciate if you could adjust the request strings in the test sets to the new format, assuming it never contains single quotes. |
test pass locally with that last commit. |
Thank you! 🙂 |
Released another patch JuliaRegistries/General#123128 |
Second PR of the series:
This one is a bit on the nose, but maybe it can be helpful.
Given that the request bodies provided from the download page are valid JSON, instead of using
py2ju
we can simply useJSON.parse
with this change the usability would be almost exactly like the python APISo far I still haven't encountered a request in a format that wasn't already valid JSON.
In any case, it is still backwards compatible with using
py2ju
.