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.
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.
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
Install the dependencies for this project with:
pip install -r requirements.txt
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).
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.
-
Log into your cluster from the command line (using
oc login
) and ensure you're in the project where you have installed ST4SD (usingoc project
). -
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
. -
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.
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
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
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
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.
Please feel free to reach out to one of the maintainers listed in the MAINTAINERS.md page.
We always welcome external contributions. Please see our guidance for details on how to do so.
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}
}
This project is licensed under the Apache 2.0 license. Please see details here.