Skip to content
A cookiecutter template for Chris app plugins
Python Shell Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
hooks
{{cookiecutter.app_repo_name}} Add current module directory to the Python search path. This allows t… May 10, 2019
.gitignore
LICENSE Initial commit Oct 3, 2017
README.rst Update README.rst Aug 23, 2019
cookiecutter.json

README.rst

cookiecutter-chrisapp

A cookiecutter template for ChRIS plugin apps.

Abstract

This page describes how to get started with creating a ChRIS plugin. The first-time steps typically involve:

  • Installing a python virtual environment for development.
  • Creating (if not already done) github and dockerhub accounts.
  • Checking out this repo and running the script and then associating the app you are creating with both github and dockerhub.

Requirements

  • Python and pip (which is usually installed with Python)
  • Latest Docker (17.04.0+) if you want to test your plugin's docker image and containers in your local machine. Visit https://docs.docker.com/install/ for installation directions

Install virtualenv and virtualenvwrapper

pip install virtualenv virtualenvwrapper

note: anaconda users on macOS should use the conda environment tools directly instead. See this thread and the linked discussion on the anaconda mailing list. A working set of commands is noted here.

Setup your virtual environments

Create a directory for your virtual environments e.g:

mkdir ~/python_envs

Open your .bashrc file:

vim ~/.bashrc

Add these two lines to your .bashrc file:

export WORKON_HOME=~/python_envs
source $(which virtualenvwrapper.sh | head -n 1)

Create a new Python3 virtual environment:

mkvirtualenv --python=python3 chrisapp_env

To activate chrisapp_env:

workon chrisapp_env

To deactivate chrisapp_env:

deactivate

GitHub Account

Create a GitHub account on https://github.com/ if you don't already have one.

Docker Hub Account

Create a Docker Hub account on https://hub.docker.com/ if you don't already have one.

Quickstart

The steps below show how to quickly create and setup a new ChRIS plugin app project.

  1. Create a Python3 virtual environment for your plugin apps and activate it if you haven't created it yet (follow steps in Requirements).

  2. Install the latest Cookiecutter in chrisapp_env if you haven't installed it yet:

    pip install -U cookiecutter
    
  3. Generate a ChRIS plugin app project:

cookiecutter https://github.com/FNNDSC/cookiecutter-chrisapp.git

In running the above command, you will be prompted for an app project name. The app project name should be a valid python module name as described here https://www.python.org/dev/peps/pep-0008/#package-and-module-names.

The interactive script will ask you to choose between two types of ChRIS plugins.

  1. FS (or Feed Synthesis) plugin app. These create (synthesize) a new top level Feed -- typically from some event (a user drags and drops files into a box; a user queries a database for data; etc). These plugins only enforce a single positional argument -- an output directory where the results of the synthesis event are stored. FS plugins create a new feed (data container) in the ChRIS system. Thus, FS plugins are always the single root of a pipeline or tree of plugin executions. If one considers a processing chain or pipeline as an abstracted linked list, an FS plugin corresponds to the head node of the list.
  2. DS (or Data Synthesis) plugin app. These are by far the most common plugins and enforce two positional arguments: an input directory (typically the result of a previous plugin's output) and an output directory.

The first plugin of a pipeline would always be a single FS plugin followed by a (possibly branched) chain of DS plugins creating files in the same single feed that was created by the root FS plugin. Most of the time you will be creating a DS plugin when integrating your software application in ChRIS.

  1. Create a new repository on https://github.com/your_github_username with the same name as the app project directory generated by the previous cookiecutter command. Make sure that the repository is public. Don’t initialize the repository with a README, a license or a .gitignore file.

  2. Change the current working directory to the app project and initialize this local directory as a Git repository:

    git init
    
  3. Add and commit the files in the local repository:

    git add .
    git commit -m "First commit"
    
  4. Add the URL for the remote Github repository created in step 4 where your local repository will be pushed:

    git remote add origin **remote_Github_repository_URL** (eg. https://github.com/FNNDSC/pl-neuproseg.git)
    git remote -v
    
  5. Push the changes in your local repository to GitHub:

    git push origin master
    
  6. Create a new repository with automated build on your Docker Hub account (https://hub.docker.com).

    Once you log in, click the Create Repository + button. At the top of the page, enter a name for the dockerhub repository -- this name can be anything of course. We recommend using the same as the github repo. Then, click on the github icon towards the bottom (it also should say "Connected" under the icon). For the github organization choose, for example, FNNDSC, and then within that organization select the repository created above.

    A default build rule will be provided which should be left intact. In addition to the default rule, it is extremely important that you tag your automatically built docker image with an appropriate version number based on your Github tags. Please create an additional new build rule by clicking the BUILD RULES + button. A good rule good be Source type: Tag, Source: /^[0-9.]+$/ and Docker Tag: version-{sourceref}.

    Click Create && Build button to finish the setup and trigger the automated build.

    For more information on Automated Builds, please visit https://docs.docker.com/docker-hub/builds/.

  7. Modify requirements.txt, setup.py, Dockerfile and the Python code with the proper versions of Python dependencies and libraries and push your changes to Github.

    Look at https://github.com/FNNDSC/pl-simplefsapp (a simple fs plugin) and https://github.com/FNNDSC/pl-simpledsapp (a simple ds plugin) for guidance on getting started with your ChRIS plugin!

  8. Once you've developed and properly tested your plugin app you can make a new release by running the provided release.sh script with a version number for the release.

  9. Finally please consult the wiki to learn how to register your containerized plugin app to ChRIS and the ChRIS store.

You can’t perform that action at this time.