Open jeffbaumes opened 6 years ago
@manthey @aashish24 @cjh1 @cryos @zachmullen, this is for later discussion on jupyter-girder strategy. This notebook includes a proof-of-concept implementation similar to (1) above: a nb_open
function that acts kind of like Python's open
, supporting r
, rb
, w
, wb
modes. Opening in read mode loads the entire file immediately, and writing will only write to Girder when the file is closed (i.e. the with
context ends).
@cryos had the idea of accessing data from a general jupyter ContentsManager. This is an implementation of that concept, which is interesting in that there is nothing about it that requires a Girder ContentsManager. It works for any ContentsManager including the built-in filesystem based one. @cjh1 is the one who figured out how to get access to the jupyter session token inside the notebook to make this work.
The notebook shows (1) reading, displaying, then writing back a copy of an image stored in Girder, (2) reading a CSV file stored in Girder into a pandas dataframe, (3) showing an error when a file is not found.
Limitiations include (1) it only works with absolute Girder paths, not paths relative to the notebook file as you might expect, (2) if there are multiple jupyter labs running on the same machine it does not know which one to get content from (arbitrarily chooses the first one), (3) you currently need to use the contextmanager with
statement, it does not support f = open(...)
with a explicit f.close()
like Python's open
does.
Assuming we have #23, it would be great to add a few convenience methods which also know the current notebook's path inside Girder in order to read/write Girder files. Some options:
open
. In this case, it would seem that the contents manager is not even needed. Thoughts @manthey?