Skip to main content

FAIR-Cells allows the user to interactively create a Docker image from a Jupyter Notebook.

Project description

Upload Python Package

FAIR-Cells

FAIR-Cells is a Jupyter Notebook extension that allows the user to interactively create a Docker image from a Jupyter Notebook. Our tool can be used to generate Docker images from single cells of a Jupyter Notebook. The generated image will run a web service that will output the specified cell. This includes image outputs like plots. Code introspection for Python enables the services to change cell output at service run-time.

FAIR-Cells Demo

Among other things, FAIR-Cells is useful for reusing notebook components in workflows that support web services.

... More information to follow ...

Installation

FAIR-Cells can be downloaded using pip. It then needs to be enabled using three Jupyter commands. Docker is required for the extension to have any effect.

Optionally, you may want to set up a virtual python environment:

$ python3 -m venv venv
$ source ./venv/bin/activate
$ pip install jupyter matplotlib docker fair-cells
$ jupyter serverextension enable --py fair-cells
$ jupyter nbextension install --py fair-cells --user
$ jupyter nbextension enable fair-cells --user --py

Start jupyter notebook with:

$ jupyter notebook

You can now open http://localhost:8888

Run with Docker

docker run -it -p 8888:8888  -e GEN_CERT=yes -v /var/run/docker.sock:/var/run/docker.sock qcdis/fair-cells 

Development

To keep your system clean it is recommended to develop using Docker. The following command will run a Jupyter Notebook server with FAIR-Cells enabled at http://localhost:8888. Autoreload is enabled for Python files, you will need to reload your browser to see changes in the front-end.

$ docker-compose up --build main

To test the helper server that runs inside the container run the following command. This uses a dummy notebook that can be found in docker/helper_dummy. The notebook will be available at http://localhost:10000

$ docker-compose up --build helper

Tutorial

Prerequisites

Make sure you have Docker installed. To verify you may run:

$ [sudo] docker run hello-world

To be able to publish images to dockerhub you will need to create an account at https://registry.hub.docker.com/signup As soon as you have created you account create an Access Token that you will use to publish images. To create an Access Token in dockerhub you may follow these instructions: https://docs.docker.com/docker-hub/access-tokens/

Start FAIR-Cells

Start the docker container with jupyter and FAIR-Cells enabled:

 [sudo] docker run -it -p 8888:8888  -v /var/run/docker.sock:/var/run/docker.sock qcdis/fair-cells:release-1.0.13-winter-school-20

With your browser (preferably chrome or chromium) open http://127.0.0.1:8888/. The 'work' folder of the Jupyter server should contain a notebook named 'classifiers.ipynb'

Execute Notebook

Open the notebook. The first cell provides a description of the notebook. Execute all the cells you should see the results of each classifier's accuracy.

You may experiment with different values for 'n_samples', 'n_features' and 'train_samples'. You may notice that as you increase the values of 'n_samples', 'n_features' and 'train_samples' the cell execution is taking longer. Also, it would take a long time to manually adjust all values to find the optimal combination.

Dockerize Cell

We need 'dockerize' the 3rd cell, so we can use it as an independent service. To do that start FAIR-Cells by clicking on the last icon on the second row.

Fill in the fields of FAIR-Cells as shown in the images bellow. Make sure that the in 'Image name' field has the form: 'REPO/NAME', where 'REPO' you should put your dockerhub username. In the 'NAME' you may add any name you like.

Make sure you select the variables 'n_samples', 'n_features' and 'train_samples' as 'query', so we can change their values while calling the service. You may leve the rest as 'disabled'

Next you may press 'Build' to 'dockerize' the selected cell. This process should take approximately 5 minutes.

When the process is done you will see the log message on the text area next to the build button:

Test Dockerized Cell

As soon as the cell has been 'dockerized' you may start it as a service by selecting the 'Run' tab:

Press the 'Run' button and as soon as the state changes to create open a new tab and fill in the address: http://localhost:10000/. This will call the cell with the 'n_samples', 'n_features' and 'train_samples' set to their default. If you want to change these values set the address to http://localhost:10000/?train_samples=1000&n_samples=100000&n_features=10 or any other integers.

Go back to Jupyter and stop the service by pressing 'stop'

Publish Dockerized Cell

Open the 'Publish' tab and fill in your username and Access Token and press 'Login'. If the login was successful you can press 'Publish'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

FAIR-Cells-1.0.15.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FAIR_Cells-1.0.15-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file FAIR-Cells-1.0.15.tar.gz.

File metadata

  • Download URL: FAIR-Cells-1.0.15.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for FAIR-Cells-1.0.15.tar.gz
Algorithm Hash digest
SHA256 6ef95a969abd7eb1d552cdaedef5c2d6ea25cd8ae2593f62d388d00301d6a7e8
MD5 94d9aece709be73edf4716bd05f5fd85
BLAKE2b-256 7a337762cca94c8160912f18a1c59633fe6023845110f70565bbe0f96b88bb1b

See more details on using hashes here.

File details

Details for the file FAIR_Cells-1.0.15-py3-none-any.whl.

File metadata

  • Download URL: FAIR_Cells-1.0.15-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for FAIR_Cells-1.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 def21a6d4635a6748d3da9777bffff1b041de9b6ebf5a516295ee2f7c5c1174f
MD5 a6179fe89abb3518b42902d4ff99e5ac
BLAKE2b-256 cfdcf5872b804666105fa0e518179d28b494c90d66844ab30847f7c955a36041

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page