Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

205 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alplakes FastAPI

License: MIT Python

This is a repository for Eawag SURF fastapi, initially developed for the ALPLAKES project.

Endpoints can be found in app/main.py

The documentation pages are available at the following:

FastAPI

Production Deployment

1. Install docker

Follow the official install instructions here

Then run docker login to enable access to private docker images.

2. Clone repository

sudo apt-get -y update && sudo apt-get -y install git
git clone https://github.com/eawag-surface-waters-research/alplakes-fastapi.git
mkdir -p filesystem

3. Create .env file

Replace example filesystem path with correct path. For local development this is likely to be the filesystem folder within the repository. For production environments this may be on another drive.

cd alplakes-fastapi
cp env.example .env
nano .env

4. Launch service

cd alplakes-fastapi
docker compose up --build -d

Restart service

When there are changes to the API the service needs to be rebuilt to reflect those changes.

docker compose down
docker compose up --build -d

Local Development

1. Install virtual environment

conda create --name fastapi python=3.12
conda activate fastapi
conda install --file requirements.txt

2. Run API

Manually set filesystem path in main.py if files are NOT located in the filesystem folder within the repository.

conda activate fastapi
uvicorn app.main:app --host 0.0.0.0 --reload

Run Tests

Pytest can be directly run with FastAPI. Tests are located in the file app/test_main.py.

Install pytest

pip install pytest

Download test files

Test files need to be downloaded from "URL_TO_FOLLOW" into the filesystem folder. The folder structure should look like:

├── media
│   ├── bafu
│   │   └── hydrodata
│   ├── meteoswiss
│   │   └── cosmo
│   │   └── meteodata
│   └── simulations
│       └── delft3d-flow
├── .gitkeep               

Run tests

Navigate to the top directory of the repository to run pytest.

pytest

About

FastAPI for the Alplakes project

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages