Giter Club home page Giter Club logo

tiledb-cloud-jupyter-contents's Introduction

TileDB Cloud Jupyter Contents

This package contains a juypterlab contents plugin to allow storing jupyter notebooks as TileDB arrays on TileDB Cloud. It also supports local filesystem access so you can store notebooks locally as traditional json files or on the cloud as TileDB Arrays.

Usage

To use the content manager, first you must install it:

python setup.py install

Next adjust your jupyter config usually /etc/jupyter/jupyter_notebook_config.py or you can create a jupyter_notebook_config.py file in your current working directory.

Add the following line:

c.NotebookApp.contents_manager_class = "tiledbcontents.TileDBCloudContentsManager"

Local testing

The easiest way to test this locally is to work in a virtual environment. You can use your preferred virtual environment management tool (e.g. Conda), or to set up a fresh venv, run:

$ cd path/to/TileDB-Cloud-Jupyter-Contents
$ python3 -m venv venv
$ . ./venv/bin/activate

Install all the dependencies, and set yourself up for development:

$ pip install --editable .
[...]
$ pip install jupyter
[...]

Jupyter itself is not included in the install_requires because while it is useful for development and testing, this code does not actually depend upon it. Now you have all the prerequisites installed, and the tiledbcontents package points to the files in your working directory.

If you have not already logged into TileDB Cloud, you will need to do so. From a Python console, run the tiledb.cloud.login function. In this example we use an API token that we created, but you can also use a username and password.

$ python
>>> import tiledb.cloud
>>> # This is a dummy value; replace it with your own token or user/pass.
>>> tiledb.cloud.login(token='aHR0cHM6Ly95b3V0dS5iZS9vSGc1U0pZUkhBMA==')

This will store a credential in your home directory that will be used by default when accessing TileDB Cloud services through the API.

The only remaining step is to launch Jupyter and configure it to use the TileDBCloudContentsManager class:

$ jupyter notebook --NotebookApp.contents_manager_class=tiledbcontents.TileDBCloudContentsManager

This will run a local test Jupyter notebook server without changing your default Jupyter configuration. You can make this your default by following the instructions in "Usage" above.

Now the server is running, and you just need to follow Jupyter's directions to connect! Certain actions (like file navigation) may take longer than you would expect, because it has to communicate with the remote TileDB Cloud server.

How it Works

The package works by storing the notebook in a dense array with certain metadata to indicate the current size and type. We also set certain TileDB Cloud tags to associate the array as a Jupyter notebook.

TileDB Array Schema

The array is created as a 1 dimensional dense array with a single attribute of contents, which is the bytes of the notebook json format.

schema = tiledb.ArraySchema(
    domain=dom,
    sparse=True,
    attrs=[tiledb.Attr(name="contents", dtype=numpy.uint8, filters=tiledb.FilterList(tiledb.ZstdFilter()))],
    ctx=tiledb.cloud.Ctx(),
)

Listing

The listing of cloud notebooks happens through the traditional array listings. We use the special tag of __jupyter-notebook, to filter for arrays which are actually notebooks.

The listings show up under the "cloud" folder of the notebook file browser.

tiledb-cloud-jupyter-contents's People

Contributors

shelnutt2 avatar antalakas avatar thetorpedodog avatar nguyenv avatar sarantopouloskon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.