Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Running the application locally

Alan Wu edited this page Jun 25, 2019 · 7 revisions

Introduction

This page describes the required steps to setup a local development environment for the SPARC Data Portal.

Prerequisites

  • Make sure you have Python and Pip installed.

  • Install VirtualEnv in order to create a python virtual environment for your Python packages in this project.

pip install virtualenv

Fork the Github repository

Fork the repository into your own Github account. Visit the Github documentation for detailed information on how to fork the repository, how to clone the forked repository to your local machine and how to create pull-requests to integrate any changes you made back into the main nih-sparc/data-portal repository.

Create a virtual environment for Python

  • Using the terminal, go into the repository folder and instantiate a virtual environment:
cd <path-to-project-folder>
virtualenv venv
  • activate the environment:
source ./venv/bin/activate

With the virtual environment activated, you can install all the python dependencies for the project and run the web-application server. You will have to activate the virtual environment any time you open a terminal window and want to interact with the webapplication. You can de-activate the virtual environment using the deactivate command. Please see the Virtualenv documentation for more information.

Install Dependencies

All Python dependencies are listed in the requirements.txt file. Install the dependencies using pip. Note that the dependencies will be installed in the venv folder which is ignored by Git. Make sure you don't change the name of the virtual environment as this will result in Python dependencies being included in the Git repository.

pip install -r requirements.txt

Setting environment variables

For running the platform locally, make sure you set the right environment variables. Make sure you don't store any TOKEN or API_SECRET in code that is committed to the repository.

export BLACKFYNN_API_TOKEN=xxxxxxxx-8b7e-d12458571117
export BLACKFYNN_API_SECRET=xxxxxxxxxx70-612411755996
export BLACKFYNN_API_HOST=https://api.blackfynn.io
export BLACKFYNN_CONCEPTS_API_HOST=https://concepts.api.blackfynn.io

Build Modules & Track updates

Some modules will require a separate build process to generate the static assets for the web application. During deployment, this is handled by Heroku but you will manually have to trigger this process when you run the web application locally by running the following commands in separate terminal windows:

npm run dev-build-shared
npm run dev-build-dashboard
npm run dev-build-browse

This will install the dependencies in the modules and build the web assets using webpack. At the end of the build, it will continue to watch for changes in your files and automatically trigger a rebuild when that happens. You can use Ctrl-C to exit this service.

Run the application locally

With the Webpack Filewatcher running, open a second terminal windown and start the application:

source ./venv/bin/activate
make serve

Submitting pull requests

Once you have committed changes to your local forked repository, and you have thoroughly tested the functionality of your added content, you can submit a pull request into the Master branch of the nih-sparc/data-portal repository. Your code will have to be reviewed before it will be merged into the main repository.