-
Notifications
You must be signed in to change notification settings - Fork 2
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 #85 from ukaea/nathan/deps-in-pyproject.toml
Nathan/deps in pyproject.toml
- Loading branch information
Showing
8 changed files
with
1,179 additions
and
133 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,53 +1,29 @@ | ||
# FAIR MAST Data Management System | ||
|
||
## Overview | ||
|
||
|
||
## Development Setup | ||
|
||
### Mac Users: | ||
### Mac Users | ||
|
||
If you are using Mac for development, use [podman](https://podman.io/docs/installation) instead of docker. Follow the installation guide to set it up, then follow the below set up. | ||
If you are using Mac for development, use [podman](https://podman.io/docs/installation) instead of docker. Follow the installation guide to set it up, then follow the below set up. | ||
|
||
### Linux/Windows Users: | ||
### Linux/Windows Users | ||
|
||
If using Linux or Windows, you need to make sure you have [docker](https://www.docker.com/get-started/) and `docker-compose` installed on your system. | ||
|
||
### Setup | ||
|
||
We will be using the Python package manager [uv](https://astral.sh/blog/uv) to install our dependencies. As a first step, make sure this is installed with: | ||
```bash | ||
pip install uv | ||
``` | ||
Secondly, clone the repository: | ||
|
||
```bash | ||
git clone [email protected]:ukaea/fair-mast.git | ||
cd fair-mast | ||
``` | ||
|
||
You can use either `conda` or `venv` to set up the environment. Follow the below instructions depending on your preference. | ||
### Option 1: Using Conda | ||
Assuming you already have conda installed on your system: | ||
```bash | ||
conda create -n mast python=3.11 | ||
conda activate mast | ||
uv pip install -r docs/requirements.txt | ||
``` | ||
|
||
### Option 2: Using venv | ||
Ensure you are using Python version `3.11`: | ||
```bash | ||
uv venv venv | ||
source venv/bin/activate | ||
uv pip install -r docs/requirements.txt | ||
``` | ||
|
||
Use `uv --help` for additional commands, or refer to the documentation if needed. | ||
|
||
### Start the Data Management System | ||
|
||
Run the development container to start the postgres database, fastapi, and minio containers locally. The development environment will watch the source directory and automatically reload changes to the API as you work. | ||
|
||
### Mac Users: | ||
#### Mac Users | ||
|
||
```bash | ||
podman compose \ | ||
|
@@ -64,7 +40,7 @@ podman compose -f dev/docker/docker-compose.yml down | |
podman volume rm --all | ||
``` | ||
|
||
### Linux/Windows Users: | ||
#### Linux/Windows Users | ||
|
||
```bash | ||
docker-compose \ | ||
|
@@ -76,15 +52,14 @@ up \ | |
|
||
The following services will be started: | ||
|
||
- FastAPI REST & GraphQL Server - will start running at `http://localhost:8081`. | ||
- The REST API documentation is at `http://localhost:8081/redoc`. | ||
- The GraphQL API documentation is at `http://localhost:8081/graphql`. | ||
- Postgres Database Server - will start running at `http://localhost:5432` | ||
- Postgres Admin Server - will start running at `http://localhost:8081/pgadmin` | ||
- Minio S3 Storage Server - will start running at `http://localhost:9000`. | ||
- The admin web GUI will be running at `http://localhost:8081/minio/ui`. | ||
- FastAPI REST & GraphQL Server - will start running at `http://localhost:8081`. | ||
- The REST API documentation is at `http://localhost:8081/redoc`. | ||
- The GraphQL API documentation is at `http://localhost:8081/graphql`. | ||
- Postgres Database Server - will start running at `http://localhost:5432` | ||
- Postgres Admin Server - will start running at `http://localhost:5050` | ||
|
||
### Populate the Database | ||
|
||
To create the database and populate it with content we need to get the metadata files. These are stored in the repository using [Git LFS](https://git-lfs.com). | ||
|
||
To retrieve these data files, follow the below instructions in your terminal: | ||
|
@@ -95,35 +70,32 @@ git lfs fetch | |
git lfs pull | ||
``` | ||
|
||
Assuming the files have been pulled successfully, the data files should exist within `tests/mock_data/mini` in the local directory. We can | ||
Assuming the files have been pulled successfully, the data files should exist within `tests/mock_data/mini` in the local directory. We can | ||
create the database and ingest data using the following command: | ||
|
||
### Mac Users: | ||
#### Mac Users | ||
|
||
```bash | ||
podman exec -it mast-api python -m src.api.create /code/data/mini | ||
podman exec -it mast-api python -m src.api.create /code/data/index | ||
``` | ||
|
||
### Linux/Windows Users: | ||
#### Linux/Windows Users | ||
|
||
```bash | ||
docker exec -it mast-api python -m src.api.create /code/data/mini | ||
docker exec -it mast-api python -m src.api.create /code/data/index | ||
``` | ||
|
||
### Running Unit Tests | ||
|
||
Verify everything is setup correctly by running the unit tests. | ||
|
||
To run the unit tests, input the following command inside your environment: | ||
Follow the below instructions to set up the environment. | ||
|
||
```bash | ||
python -m pytest -rsx tests/ --data-path="INSERT FULL PATH TO DATA HERE" | ||
uv run pytest | ||
``` | ||
|
||
The data path will be will be along the lines of `~/fair-mast/tests/mock_data/mini`. | ||
|
||
This will run some unit tests for the REST and GraphQL APIs against a testing database, created from the data in `--data-path`. | ||
|
||
### Production Deployment | ||
## Production Deployment | ||
|
||
To run the production container to start the postgres database, fastapi, and minio containers. This will also start an nginx proxy and make sure https is all setup | ||
|
||
|
@@ -138,11 +110,19 @@ docker compose --env-file dev/docker/.env.dev -f dev/docker/docker-compose.yml | |
``` | ||
|
||
To also destory the volumes (including the metadatabase) you may add the volumes parameter: | ||
|
||
```bash | ||
docker compose --env-file dev/docker/.env.dev -f dev/docker/docker-compose.yml -f dev/docker/docker-compose-prod.yml down --volumes | ||
``` | ||
|
||
**Note** that every time you destory volumes, the production server will mint a new certificate for HTTPS. Lets Encrypt currently limits this to [5 per week](https://letsencrypt.org/docs/duplicate-certificate-limit/) | ||
**Note:** Every time you destory volumes, the production server will mint a new certificate for HTTPS. Lets Encrypt currently limits this to [5 per week](https://letsencrypt.org/docs/duplicate-certificate-limit/). | ||
|
||
You'll need to download and ingest the production data like so: | ||
|
||
```bash | ||
mkdir -p data/mast/meta | ||
rsync -vaP <CSD3-USERNAME>@login.hpc.cam.ac.uk:/rds/project/rds-sPGbyCAPsJI/archive/metadata data/ | ||
``` | ||
|
||
```bash | ||
docker exec -it mast-api python -m src.api.create /code/data/index | ||
|
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
This file was deleted.
Oops, something went wrong.
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
Empty file.
Oops, something went wrong.