Skip to content

Commit f03c067

Browse files
Merge pull request #85 from ukaea/nathan/deps-in-pyproject.toml
Nathan/deps in pyproject.toml
2 parents a2408ee + 98afdac commit f03c067

File tree

8 files changed

+1179
-133
lines changed

8 files changed

+1179
-133
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ jobs:
3838
run: |
3939
git lfs fetch
4040
git lfs pull
41+
pip install --upgrade pip
4142
pip install uv
42-
uv venv venv
43-
source venv/bin/activate
44-
uv pip install -r docs/requirements.txt
43+
uv sync
4544
4645
- name: Run tests
4746
run: |
48-
source venv/bin/activate
49-
python -m pytest -rsx tests/ --data-path=/home/runner/work/fair-mast/fair-mast/tests/mock_data/index
47+
uv run pytest -rs
5048
5149
ruff-code-check:
5250
runs-on: ubuntu-latest

README.md

Lines changed: 31 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,29 @@
11
# FAIR MAST Data Management System
22

3-
## Overview
4-
5-
63
## Development Setup
74

8-
### Mac Users:
5+
### Mac Users
96

10-
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.
7+
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.
118

12-
### Linux/Windows Users:
9+
### Linux/Windows Users
1310

1411
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.
1512

1613
### Setup
1714

18-
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:
19-
```bash
20-
pip install uv
21-
```
2215
Secondly, clone the repository:
16+
2317
```bash
2418
git clone [email protected]:ukaea/fair-mast.git
2519
cd fair-mast
2620
```
2721

28-
You can use either `conda` or `venv` to set up the environment. Follow the below instructions depending on your preference.
29-
### Option 1: Using Conda
30-
Assuming you already have conda installed on your system:
31-
```bash
32-
conda create -n mast python=3.11
33-
conda activate mast
34-
uv pip install -r docs/requirements.txt
35-
```
36-
37-
### Option 2: Using venv
38-
Ensure you are using Python version `3.11`:
39-
```bash
40-
uv venv venv
41-
source venv/bin/activate
42-
uv pip install -r docs/requirements.txt
43-
```
44-
45-
Use `uv --help` for additional commands, or refer to the documentation if needed.
46-
4722
### Start the Data Management System
23+
4824
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.
4925

50-
### Mac Users:
26+
#### Mac Users
5127

5228
```bash
5329
podman compose \
@@ -64,7 +40,7 @@ podman compose -f dev/docker/docker-compose.yml down
6440
podman volume rm --all
6541
```
6642

67-
### Linux/Windows Users:
43+
#### Linux/Windows Users
6844

6945
```bash
7046
docker-compose \
@@ -76,15 +52,14 @@ up \
7652

7753
The following services will be started:
7854

79-
- FastAPI REST & GraphQL Server - will start running at `http://localhost:8081`.
80-
- The REST API documentation is at `http://localhost:8081/redoc`.
81-
- The GraphQL API documentation is at `http://localhost:8081/graphql`.
82-
- Postgres Database Server - will start running at `http://localhost:5432`
83-
- Postgres Admin Server - will start running at `http://localhost:8081/pgadmin`
84-
- Minio S3 Storage Server - will start running at `http://localhost:9000`.
85-
- The admin web GUI will be running at `http://localhost:8081/minio/ui`.
55+
- FastAPI REST & GraphQL Server - will start running at `http://localhost:8081`.
56+
- The REST API documentation is at `http://localhost:8081/redoc`.
57+
- The GraphQL API documentation is at `http://localhost:8081/graphql`.
58+
- Postgres Database Server - will start running at `http://localhost:5432`
59+
- Postgres Admin Server - will start running at `http://localhost:5050`
8660

8761
### Populate the Database
62+
8863
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).
8964

9065
To retrieve these data files, follow the below instructions in your terminal:
@@ -95,35 +70,32 @@ git lfs fetch
9570
git lfs pull
9671
```
9772

98-
Assuming the files have been pulled successfully, the data files should exist within `tests/mock_data/mini` in the local directory. We can
73+
Assuming the files have been pulled successfully, the data files should exist within `tests/mock_data/mini` in the local directory. We can
9974
create the database and ingest data using the following command:
10075

101-
### Mac Users:
76+
#### Mac Users
10277

10378
```bash
104-
podman exec -it mast-api python -m src.api.create /code/data/mini
79+
podman exec -it mast-api python -m src.api.create /code/data/index
10580
```
10681

107-
### Linux/Windows Users:
82+
#### Linux/Windows Users
10883

10984
```bash
110-
docker exec -it mast-api python -m src.api.create /code/data/mini
85+
docker exec -it mast-api python -m src.api.create /code/data/index
11186
```
11287

11388
### Running Unit Tests
89+
11490
Verify everything is setup correctly by running the unit tests.
11591

116-
To run the unit tests, input the following command inside your environment:
92+
Follow the below instructions to set up the environment.
11793

11894
```bash
119-
python -m pytest -rsx tests/ --data-path="INSERT FULL PATH TO DATA HERE"
95+
uv run pytest
12096
```
12197

122-
The data path will be will be along the lines of `~/fair-mast/tests/mock_data/mini`.
123-
124-
This will run some unit tests for the REST and GraphQL APIs against a testing database, created from the data in `--data-path`.
125-
126-
### Production Deployment
98+
## Production Deployment
12799

128100
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
129101

@@ -138,11 +110,19 @@ docker compose --env-file dev/docker/.env.dev -f dev/docker/docker-compose.yml
138110
```
139111

140112
To also destory the volumes (including the metadatabase) you may add the volumes parameter:
113+
141114
```bash
142115
docker compose --env-file dev/docker/.env.dev -f dev/docker/docker-compose.yml -f dev/docker/docker-compose-prod.yml down --volumes
143116
```
144117

145-
**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/)
118+
**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/).
119+
120+
You'll need to download and ingest the production data like so:
121+
122+
```bash
123+
mkdir -p data/mast/meta
124+
rsync -vaP <CSD3-USERNAME>@login.hpc.cam.ac.uk:/rds/project/rds-sPGbyCAPsJI/archive/metadata data/
125+
```
146126

147127
```bash
148128
docker exec -it mast-api python -m src.api.create /code/data/index

dev/docker/api.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ WORKDIR /code
33

44
RUN pip install uv
55

6-
COPY docs/requirements.txt /code/requirements.txt
6+
COPY pyproject.toml /code/pyproject.toml
77

8-
RUN uv pip install --system --no-cache -r /code/requirements.txt
8+
RUN uv pip install . --system
99

1010
COPY ./src /code/src
1111

dev/docker/docker-compose.yml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
version: '3.8'
21
services:
3-
42
# Service for hosting the API.
53
# This container runs the FastAPI REST and GraphQL APIs
64
api:
@@ -32,41 +30,6 @@ services:
3230
networks:
3331
- dbnetwork
3432

35-
# Service for the Minio instance
36-
# This container runs the minio S3 buckets and console
37-
# minio:
38-
# image: minio/minio
39-
# container_name: minio
40-
# ports:
41-
# - "9000:9000"
42-
# - "9001:9001"
43-
# volumes:
44-
# - ./data/mast/s3data:/mnt/data
45-
# environment:
46-
# MINIO_ROOT_USER: ${MINIO_USER}
47-
# MINIO_ROOT_PASSWORD: ${MINIO_PASSWORD}
48-
# MINIO_VOLUMES: "/mnt/data"
49-
# command: ['server', '/mnt/data', '--console-address', ":9001"]
50-
# networks:
51-
# - dbnetwork
52-
53-
# # This service a bucket for the mast data is none exists.
54-
# createbuckets:
55-
# image: minio/mc
56-
# depends_on:
57-
# - minio
58-
# volumes:
59-
# - ./data/:/data
60-
# entrypoint: >
61-
# /bin/sh -c "
62-
# /usr/bin/mc alias set srv https://minio:9000 minio99 minio123;
63-
# /usr/bin/mc mb srv/mast;
64-
# /usr/bin/mc anonymous set public srv/mast;
65-
# exit 0;
66-
# "
67-
# networks:
68-
# - dbnetwork
69-
7033
# Service for the PostgreSQL Database
7134
# This container runs the PostgreSQL database which contains the metadata for MAST.
7235
meta_database:
@@ -85,7 +48,6 @@ services:
8548
networks:
8649
- dbnetwork
8750

88-
8951
# Service for pgadmin
9052
# This container runs a pgadmin instance for administering the database
9153
pgadmin:

docs/requirements.txt

Lines changed: 0 additions & 34 deletions
This file was deleted.

pyproject.toml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name = "fair-mast"
33
version = "1.0"
44
description = "A data management system for Tokamak data"
55
readme = "README.md"
6-
requires-python = ">=3.8"
7-
license = { name = "MIT" }
6+
requires-python = ">=3.9, <3.13"
87
authors = [
98
]
109
maintainers = [
@@ -15,11 +14,43 @@ maintainers = [
1514

1615
classifiers = [
1716
"Development Status :: 4 - Beta",
18-
"Programming Language :: Python",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"License :: OSI Approved :: MIT License",
22+
]
23+
dependencies = [
24+
"dask>=2024.8.0",
25+
"fastapi-pagination>=0.12.31",
26+
"fastapi>=0.115.2",
27+
"jinja2>=3.1.4",
28+
"numpy<2",
29+
"pandas==2.0.3",
30+
"psycopg2-binary>=2.9.10",
31+
"pyarrow>=17.0.0",
32+
"sqlakeyset>=2.0.1726021475",
33+
"sqlalchemy-utils>=0.41.2",
34+
"sqlalchemy<2",
35+
"sqlmodel>=0.0.11",
36+
"strawberry-graphql>=0.246.2",
37+
"tqdm>=4.66.5",
38+
"ujson>=5.10.0",
39+
"uvicorn>=0.32.0",
1940
]
2041

2142
[project.urls]
2243
repository = "https://github.com/ukaea/fair-mast"
2344

2445
[tool.ruff]
2546
exclude = ["docs/*.ipynb", "notebooks/*.ipynb", "src/metadata/*.ipynb", "src/api/static"]
47+
48+
[tool.uv]
49+
dev-dependencies = [
50+
"httpx>=0.27.2",
51+
"pint>=0.24.3",
52+
"pytest-benchmark>=4.0.0",
53+
"pytest>=8.3.3",
54+
"xarray>=2024.7.0",
55+
"zarr>=2.18.2",
56+
]

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)