Data server for data plots.
Developer documentation at https://livedata-ornl.readthedocs.io/en/latest/
- Conda / Mamba/Miniforge
- Docker and Docker Compose
- direnv (optional)
-
Clone the repository and
cd
into the project directory. -
Create a conda environment
livedata
, containing all the dependenciesconda env create -f environment.yml conda activate livedata
-
To deploy this application locally, you will need to set a number of environment variables, for example (bash):
export DATABASE_NAME=livedatadb export DATABASE_USER=livedatauser export DATABASE_PASS=livedatapass export DATABASE_HOST=db export DATABASE_PORT=5432 export LIVE_PLOT_SECRET_KEY="secretKey" # These need to be set for `pytest`, # but are not used in the docker compose export DJANGO_SUPERUSER_USERNAME=$DATABASE_USER export DJANGO_SUPERUSER_PASSWORD=$DATABASE_PASS
Notes:
-
The
DATABASE_PORT
must be set to5432
, as Postgres is configured to listen on that port by default. If you need to change the port, you will need to modify thedocker-compose.yml
file accordingly. -
It is recommended to save these variables into an
.envrc
file which can be managed by direnv. direnv will automatically load the variables when youcd
into the project directory.
-
-
After the secrets are set, type in the terminal shell:
make docker/compose/local
This command will copy
deploy/docker-compose.envlocal.yml
intodocker-compose.yml
before composing all the services.Type
make help
to learn about other macros available as make targets. For instance,make docker/pruneall
will stop all containers, then remove all containers, images, networks, and volumes.
After the setup, with the server running, you can test your setup by running pytest
:
pytest tests/test_post_get.py
# or simply
pytest
NOTE:
The environment variables DJANGO_SUPERUSER_USERNAME
and DJANGO_SUPERUSER_PASSWORD
are defined in the docker-compose.envlocal.yml
file, but pytest
does not read this file.
You must either have them exported to the shell where pytest
is to be run, as described above, or modify the pytest
command to include them, e.g.:
DJANGO_SUPERUSER_USERNAME=***** DJANGO_SUPERUSER_PASSWORD=***** pytest
- Repository managing the provision for deployment:
- hardware and networking for deployment: https://code.ornl.gov/sns-hfir-scse/infrastructure/neutrons-test-environment/-/blob/main/terraform/servers.tf#L85-97
- configuration independent of source code changes: https://code.ornl.gov/sns-hfir-scse/infrastructure/neutrons-test-environment/-/blob/main/ansible/testfixture02-test.yaml
- Repository managing deployment of the source to the provisioned hardware: https://code.ornl.gov/sns-hfir-scse/deployments/livedata-deploy
Additional documentation is available in the docs
directory. To build the documentation in your local machine,
run the following command from within directory docs/
:
make html
The documentation will be built in the docs/_build/html
directory. To view the documentation,
open the docs/_build/html/index.html
file in a web browser.