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

Support pickle output of numpy arrays for endpoints. #812

Merged
merged 1 commit into from
Mar 31, 2022
Merged

Conversation

manthey
Copy link
Member

@manthey manthey commented Mar 31, 2022

The region, thumbnail, and tile_frames endpoints can returned pickled numpy arrays.

This facilitates getting numpy data from a tile source through Girder Client. For instance, numpyarray = pickle.loads(gc.get('item/5c3e0590e45e326a5e2fb252/tiles/region', parameters={'encoding': 'pickle:' + str(pickle.HIGHEST_PROTOCOL), 'width': 2000}, jsonResp=False).content) would fetch a numpy array as efficiently as possible. The protocol will be the lower of that specified in the request and the maximum for the python version of the server. Just using 'pickle' will use protocol 4, which will work with any supported version of Python 3 -- specifying an explicit number is more efficient and adapts to clients using a Python version not otherwise supported.

The region, thumbnail, and tile_frames endpoints can returned pickled
numpy arrays.

This facilitates getting numpy data from a tile source through Girder
Client.  For instance, `numpyarray =
pickle.loads(gc.get('item/5c3e0590e45e326a5e2fb252/tiles/region',
parameters={'encoding': 'pickle:' + str(pickle.HIGHEST_PROTOCOL),
'width': 2000}, jsonResp=False).content)` would fetch a numpy array as
efficiently as possible.  The protocol will be the lower of that
specified in the request and the maximum for the python version of the
server.  Just using 'pickle' will use protocol 4, which will work with
any supported version of Python 3 -- specifying an explicit number is
more efficient and should adapt to clients using a Python version not
otherwise supported.
@manthey
Copy link
Member Author

manthey commented Mar 31, 2022

@banesullivan An equivalent endpoint or endpoint option would be useful for the django implementation -- it makes it much more convenient to process data in a Jupyter notebook when the data isn't local.

@manthey manthey merged commit 72e89cb into master Mar 31, 2022
@manthey manthey deleted the pickle-output branch March 31, 2022 14:37
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