Skip to content

REST Proxy to the ST4SD Runtime Service used by the ST4SD Registry UI. Retrieve parameterised virtual-experiment packages, experiment instances, and view logs.

License

Notifications You must be signed in to change notification settings

st4sd/st4sd-registry-backend

Repository files navigation

ST4SD Registry Backend

The ST4SD Registry backend is a proxy to the ST4SD Runtime Service for the ST4SD Registry UI. It is a simple REST API written in Python.

Quick links

Getting started

Requirements

Python

Running and developing this project requires a recent Python version, it is suggested to use Python 3.7 or above. You can find instructions on how to install Python on the official website.

Development

Creating a virtual environment (optional)

Ensure you have virtualenv installed with:

virtualenv --version

If you don't have it installed, run:

pip install virtualenv

Create a virtual environment called with:

virtualenv venv

This will create a Python virtual environment called venv. Activate it with:

source venv/bin/activate

To deactivate it, simply use:

deactivate

Installing dependencies

Install the dependencies for this project with:

pip install -r requirements.txt

Developing locally

To spin up a local development build of the ST4SD Registry Backend you will need to have a working OpenShift deployment of ST4SD, as it will have to connect to other components (the Runtime Service and the Datastore).

Getting a token to access ST4SD

As the backend will have to authenticate to ST4SD, you will need to provide a token that has sufficient authorizations. The safest option is to use the workflow-operator token.

  1. Log into your cluster from the command line (using oc login) and ensure you're in the project where you have installed ST4SD (using oc project).

  2. List the secrets available in the namespace you are in and look for ones related to the workflow-operator as follows (your output should be similar):

    oc get secrets | grep workflow-operator
    workflow-operator-dockercfg-jnlx9                   kubernetes.io/dockercfg               1      168d
    workflow-operator-token-28qgm                       kubernetes.io/service-account-token   4      168d
    workflow-operator-token-g6594                       kubernetes.io/service-account-token   4      168d

    In this example we will use workflow-operator-token-28qgm.

  3. Get the Service Account token and save it to a file:

    oc get secret workflow-operator-token-28qgm -o jsonpath='{.data.token}' | base64 -d > $HOME/.st4sd_serviceaccount_token

    This will store the token in a file called .st4sd_serviceaccount_token in your home directory.

Creating a development entry in settings.toml

The backend stores its configuration in the settings.toml file. By default it will use the production configuration, which uses internal OpenShift DNS routing. As these routes won't work outside of the cluster, we will need to provide the external ones.

In your terminal, get the external base route for your cluster with:

ST4SD_AUTH_ROUTE=$(oc get route st4sd-authentication -o jsonpath='{.spec.host}')

Run the following command from your terminal to extend the toml configuration file automatically:

echo -e "\n\n[development]
runtime_service_endpoint = \"https://${ST4SD_AUTH_ROUTE}/rs/\"
datastore_registry_endpoint = \"https://${ST4SD_AUTH_ROUTE}/ds-registry/\"
datastore_rest_endpoint = \"https://${ST4SD_AUTH_ROUTE}/ds-mongodb-proxy/\"
token_path=\"$HOME/.st4sd_serviceaccount_token\"
" >> settings.toml

Using the development configuration

To ensure the Backend uses the development configuration we need to set the ENV_FOR_DYNACONF environment variable. From your terminal run:

export ENV_FOR_DYNACONF=development

Spinning up the backend locally

We can start the local backend with:

python app.py

Note that it's normal to see the following output when launching the backend:

Unable to import pythonlsf - limited LSF functionality will be available
Unable to import tinydb module - tinydb interface not available

Lint and fix files

This project uses black to format the code. You can install it and use it to lint your code with:

pip install black
black .

Code not following black formatting will not be merged.

Help and Support

Please feel free to reach out to one of the maintainers listed in the MAINTAINERS.md page.

Contributing

We always welcome external contributions. Please see our guidance for details on how to do so.

References

If you use ST4SD in your projects, please consider citing the following:

@software{st4sd_2022,
author = {Johnston, Michael A. and Vassiliadis, Vassilis and Pomponio, Alessandro and Pyzer-Knapp, Edward},
license = {Apache-2.0},
month = {12},
title = {{Simulation Toolkit for Scientific Discovery}},
url = {https://github.com/st4sd/st4sd-runtime-core},
year = {2022}
}

License

This project is licensed under the Apache 2.0 license. Please see details here.

About

REST Proxy to the ST4SD Runtime Service used by the ST4SD Registry UI. Retrieve parameterised virtual-experiment packages, experiment instances, and view logs.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •