-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from neutrons/expiration-field
Add expiration field to DataRun model
- Loading branch information
Showing
23 changed files
with
568 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/.envrc | ||
/docker-compose.yml | ||
_version.py | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,102 @@ | ||
## live_data_server | ||
Data server for data plots | ||
# live_data_server | ||
|
||
<!-- Badges --> | ||
|
||
[![Documentation Status](https://readthedocs.org/projects/livedata-ornl/badge/?version=latest)](https://livedata-ornl.readthedocs.io/en/latest/?badge=latest) | ||
[![codecov](https://codecov.io/gh/neutrons/live_data_server/graph/badge.svg?token=niQ0AWldBd)](https://codecov.io/gh/neutrons/live_data_server) | ||
|
||
Developer documentation at https://livedata-ornl.readthedocs.io/en/latest/ | ||
Data server for data plots. | ||
|
||
## Contributing | ||
## Development | ||
|
||
Create a conda environment `livedata`, containing all the dependencies | ||
```python | ||
conda env create -f environment.yml | ||
conda activate livedata | ||
``` | ||
Developer documentation at <https://livedata-ornl.readthedocs.io/en/latest/> | ||
|
||
### Containerization | ||
### Dependencies | ||
|
||
To deploy this application locally for development you will need to assign values to the following secrets | ||
as environment variables defined in the shell's environment: | ||
```bash | ||
DATABASE_NAME | ||
DATABASE_USER | ||
DATABASE_PASS | ||
DATABASE_HOST | ||
DATABASE_PORT | ||
LIVE_PLOT_SECRET_KEY | ||
``` | ||
It is recommended to save these variables into an `.envrc` file which can be managed by | ||
[envdir](https://direnv.net/). | ||
- [Conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) / [Mamba/Miniforge](https://github.com/conda-forge/miniforge) | ||
- [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/) | ||
- [direnv](https://direnv.net/) (optional) | ||
|
||
After the secrets are set, type in the terminal shell: | ||
```bash | ||
make local/docker/up | ||
``` | ||
This command will copy `config/docker-compose.envlocal.yml` into `docker-compose.yml` before composing | ||
all the services. | ||
### Setup for Local Development | ||
|
||
1. Clone the repository and `cd` into the project directory. | ||
|
||
1. Create a conda environment `livedata`, containing all the dependencies | ||
|
||
```python | ||
conda env create -f environment.yml | ||
conda activate livedata | ||
``` | ||
|
||
1. To deploy this application locally, you will need to set a number of environment variables, | ||
for example (bash): | ||
|
||
```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**: | ||
|
||
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. | ||
- The `DATABASE_PORT` _must_ be set to `5432`, as Postgres is configured to listen on that port by default. | ||
If you need to change the port, you will need to modify the `docker-compose.yml` file accordingly. | ||
|
||
## Test & Verification | ||
- It is recommended to save these variables into an `.envrc` file which can be managed by [direnv](https://direnv.net/). | ||
direnv will automatically load the variables when you `cd` into the project directory. | ||
|
||
After starting the services with `make local/docker/up`, run the test that will post and get data: | ||
1. After the secrets are set, type in the terminal shell: | ||
|
||
```bash | ||
make docker/compose/local | ||
``` | ||
|
||
This command will copy `config/docker-compose.envlocal.yml` into `docker-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. | ||
|
||
### Testing | ||
|
||
After the setup, with the server running, you can test your setup by running `pytest`: | ||
|
||
```bash | ||
DJANGO_SUPERUSER_USERNAME=***** DJANGO_SUPERUSER_PASSWORD=***** pytest tests/test_post_get.py | ||
pytest tests/test_post_get.py | ||
# or simply | ||
pytest | ||
``` | ||
|
||
Environment variables `DJANGO_SUPERUSER_USERNAME` and `DJANGO_SUPERUSER_PASSWORD` are defined in | ||
file `docker-compose.envlocal.yml`. You need to either pass these variables with the correct values or have | ||
them exported to the shell where `pytest` is to be run. | ||
**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.: | ||
|
||
```bash | ||
DJANGO_SUPERUSER_USERNAME=***** DJANGO_SUPERUSER_PASSWORD=***** pytest | ||
``` | ||
|
||
## Deployment to the Test Environment | ||
- 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 | ||
|
||
- 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> | ||
|
||
## Building the Documentation | ||
|
||
Additional documentation is available in the `docs` directory. To build the documentation in your local machine, | ||
run the following command from within directory `docs/`: | ||
|
||
```bash | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: 80% | ||
threshold: 3% | ||
patch: | ||
default: | ||
target: 80% | ||
threshold: 10% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.