Skip to content

Collect JSON utility functions #430

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

Merged
merged 9 commits into from
Apr 23, 2019
Merged

Collect JSON utility functions #430

merged 9 commits into from
Apr 23, 2019

Conversation

jakirkham
Copy link
Member

@jakirkham jakirkham commented Apr 20, 2019

This refactors out the JSON utility functions created in PR ( #429 ) and moves them from zarr.meta to zarr.util. It also employs them in other places where the json module was being used directly. Should make it easier to leverage the buffer protocol as part of the loading process. Finally includes the encode step within json_dumps, which eliminates the need for it to be done every time json_dumps is called, which simplifies the code a bit.

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/tutorial.rst
  • Changes documented in docs/release.rst
  • Docs build locally (e.g., run tox -e docs)
  • AppVeyor and Travis CI passes
  • Test coverage is 100% (Coveralls passes)

As `ensure_text_type` is a more general utility function, go ahead and
move it over to `zarr.util` and drop it from `zarr.meta`. Though make
sure to import it into `zarr.meta` so that it can still be used there.
As `json_dumps` has broader use than just for metdata (e.g. attributes
would also benefit from it), this moves `json_dumps` to `zarr.util`.
As `json_loads` is more generally useful than just parsing metadata,
move it over to `zarr.util`. Though ensure it is still imported in
`zarr.meta`.
Should ensure that the `ConsolidatedMetadataStore` is able to handle
loading JSON data in a standard way.
As every use of `json_dumps` is followed by a call to `encode` to
convert the string to bytes, go ahead and incorporate this step in
`json_dumps`. Should make it a bit easier to use.
As the `encode` step is now part of `json_dumps`, remove that step
when using the `json_dumps` function.
After moving `encode` within `json_dumps`, there were
intermediate variables left over that weren't really needed. This
drops them.
@jakirkham
Copy link
Member Author

Planning on merging Monday evening if no comments.

@jakirkham jakirkham merged commit 48aa41d into zarr-developers:master Apr 23, 2019
@jakirkham jakirkham deleted the collect_util_funcs branch April 23, 2019 01:55
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.

1 participant