Running the Backend

Running on a local machine

This is a step-by-step description for running the backend in the case of the backend be installed locally on developer a machine.

  1. Make sure you installed everything according to Installation.

  2. Start the required component (i.e. the MQTT Broker and the Storage Proxy) refer to:

    1. Start the backend server:

      source $NRP_VIRTUAL_ENV/bin/activate
      python $HBP/nrp-backend/hbp_nrp_backend/hbp_nrp_backend/runserver.py
      

      This will start the backend server running on 127.0.0.1:5000. If you wish to run the server on another port, you have to provide another argument

      source $NRP_VIRTUAL_ENV/bin/activate
      python $HBP/nrp-backend/hbp_nrp_backend/hbp_nrp_backend/runserver.py 9000
      

      Note

      use the aliases provided by $HBP/nrp-user-scripts/nrp_aliases: nrp-backend and nrp-backend-verbose. The virtual environment will be automatically activated.

    2. Use the NRP Frontend to clone a template experiment and to launch it. If ID of the experiment is known in advance, requests can be sent using any REST client (e.g. Postman or curl)

Debugging

NRP Backend supports remote debugging two of the most common IDEs: Visual Studio Code and PyCharm. The aliases for running NRP Backend in debug mode, provided in $HBP/nrp-user-scripts/ are nrp-backend-debug-vscode and nrp-backend-debug-pycharm, respectively. When started in debug mode, NRP Backend will wait for the debugger connection on port 9991.

Below, a sample configuration from VScode’s launch.json file is listed:

{
    "name": "NRP Backend: Remote Attach",
    "type": "python",
    "request": "attach",
    "subProcess": true,
    "connect": {
        "host": "localhost",
        "port": 9991
    },
    "justMyCode": false
},

Building the documentation

General documentation and Python API

The documentation and Python API (the pages you are currently reading) is created by:

cd $HBP/nrp-backend
make doc # index at build/html/index.html

Unit testing

After downloading Installation of the NRP and its components, you can run linting checks of the NRP Backend and related modules.

In order to run linter-check, there is a dedicated script verify.sh:

cd $HBP/nrp-backend
./verify.sh #make sure it is executable

In order to tests, there is a dedicated script run_tests.sh:

cd $HBP/nrp-backend
./run_tests.sh #make sure it is executable