Notebooks Hub Developing

This section documents the local deployment for the Notebooks Hub application, including the mongo database, the API, and the UI.

Local Mongo Setup

Start the Mongo database with mongo:4.2.2 on port 27017. By default, mongodb does not come with authentication, so there is no need to enable it when testing locally. As a result, the username and password environment variables for the database can be left as an empty string in the .env file.

docker run -p 27017:27017 mongo:6.0.4

Local API Setup

Prerequisite:

  • notebooksHub mongoDb database on port 27017

  • Jupyterhub deployment URL

  1. Navigate to the package/API directory, and create the packages/API/.env file according to the variables found in the Values.yaml file within the associated Helm Deployment script.

    JUPYTERHUB_URL = JUPYTER_URL
    JUPYTERHUB_API_KEY = JUPYTER_API_KEY
    MODULE_LOCATION = 'opt/modules/'
    JUPYTERHUB_TOKEN_FILE = 'opt/jupyterhubToken/'
    DB_USER = ''
    DB_PASS = ''
    DB_HOST = localhost
    DB_PORT = 27017
    AUTH_SOURCE = 'admin'

Further, the Jupyterhub API key can be found within the corresponding Jupyterhub Secret on our Kubernetes Cluster.

  1. Set node version to 18.20.3 with nvm with npm version set to 10.7.0 and angular CLI version set to 9.1.15 (Note: Angular CLI version may be a newer version)

source ~/.nvm/nvm.sh
nvm install 18.20.3
node -v
  1. Install node modules

npm install
  1. Set the environment variables

set -a
source .env
  1. Build application with npm run build with the root packages/API/package.json

npm run build

If the dist folder does not get generated, delete ‘tsconfig.tsbuildinfo’ and ‘node_modules’, install node modules and build again

  1. Start application with npm run start

npm run start
  1. View your OpenAPI specification and test service calls at localhost:8002. If testing with postman, ‘filter’ and ‘where’ query JSON params are URL-encoded.

http://localhost:8002/explorer/

Local UI Setup

Prerequisite:

  • notebooksHub mongoDb database on port 27017

  • Jupyterhub deployment URL

  • local API deployment on port 8002

  1. Navigate to the package/UI directory, and create the packages/UI/.env file according to the variables found in the Values.yaml file within the associated Helm Deployment script.

RESPONSE_TYPE = 'code'
URL = AUTH_URL
REDIRECT_URL = 'http://localhost:4200'
TENANT = 'polus-qa'
BACKEND_URL = 'http://127.0.0.1:8002'
JUPYTERHUB_URL = JUPYTER_URL
CLIENT_ID = 'test'
CLIENT_SECRET = CLIENT_SECRET
  1. Request labshare npm access, and authenticate npm via the following command.

npm login
  1. Set node version to 18.20.3 with nvm with npm version set to 10.7.0 and angular CLI version set to 17.3.8 (Note: Angular CLI version may be a newer version)

source ~/.nvm/nvm.sh
nvm install 18.20.3
node -v
  1. Install node modules

npm install
  1. Build the library and the main app, then run it

npm run build:lib
npm run build
npm run start