Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*
!requirements.txt
!requirements.prod.txt
!app/
!marble_api/
**/__pycache__
!pyproject.toml
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Unit tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
env:
MONGODB_URI: mongodb://localhost:27017
jobs:
test:
if: github.event.pull_request.draft == false
Expand All @@ -18,7 +20,11 @@ jobs:
cache: 'pip'
- name: Install python test dependencies
run: |
pip install requirements.test.txt
pip install .[test]
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.12.0
with:
mongodb-version: latest
- name: Test with pytest
run: |
pytest ./test/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ __pycache__/
# virtual environments
venv/

# build files
build/
*.egg-info/

# sqlite files
*.sqlite
*.db
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.1
rev: v0.13.2
hooks:
# Run the linter.
- id: ruff
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM python:3.13-alpine

COPY requirements.txt requirements.prod.txt /app/

RUN python -m pip install -r /app/requirements.prod.txt

COPY app/ /app/app/
COPY marble_api/ /app/marble_api/
COPY pyproject.toml /app/pyproject.toml

WORKDIR /app

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--root-path", ""]
RUN pip install .[prod] && rm pyproject.toml

CMD ["uvicorn", "marble_api:app", "--host", "0.0.0.0", "--port", "8000", "--root-path", ""]
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@

An API for the Marble platform.

## Requirement

- MongoDB server

## Developing

To start a development server:

```sh
python3 -m pip install -r requirements.dev.txt
fastapi dev app
python3 -m pip install .[dev]
MONGODB_URI="mongodb://localhost:27017" fastapi dev marble_api
```

This assumes that you have a mongodb service running at `mongodb://localhost:27017`.

Or to start developing using docker:

```sh
docker compose -f docker-compose.dev.yml up
```

This will start a dedicated mongodb container for use with your app. Note that this will
track changes you make dynamically so you don't have to restart the container if you make
changes to the source code while the container is running.

### Contributing

We welcome any contributions to this code. To submit suggested changes, please do the following:
Expand Down Expand Up @@ -80,6 +96,16 @@ Then the `/test` route will not be available from `/v3` onwards.
To run tests:

```sh
python3 -m pip install -r requirements.test.txt
pytest test/
python3 -m pip install .[dev]
MONGODB_URI="mongodb://localhost:27017" pytest ./test
```

This assumes that you have a mongodb service running at `mongodb://localhost:27017`.

Alternatively you can run start up the development stack with docker compose and then
run tests in the docker container:

```sh
docker compose -f docker-compose.dev.yml up -d
docker compose exec marble_api pytest ./test
```
3 changes: 0 additions & 3 deletions app/__init__.py

This file was deleted.

10 changes: 0 additions & 10 deletions app/database/__init__.py

This file was deleted.

29 changes: 0 additions & 29 deletions app/database/sqlite.py

This file was deleted.

91 changes: 0 additions & 91 deletions app/versions/v1/app.py

This file was deleted.

110 changes: 0 additions & 110 deletions app/versions/v1/models.py

This file was deleted.

13 changes: 13 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
marble_api:
image: python:3.13-alpine
volumes:
- .:/app
working_dir: /app
command: ["sh", "-c", "pip install -e .[dev,test] && fastapi dev marble_api --host 0.0.0.0"]
environment:
- MONGODB_URI=mongodb://mongo:27017
ports:
- 8000:8000
mongo:
image: mongo:5.0.4
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
marble_api:
image: marbleclimate/marble-api:latest
environment:
- MONGODB_URI=mongodb://mongo:27017
ports:
- 8000:8000
mongo:
image: mongo:5.0.4
3 changes: 3 additions & 0 deletions marble_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from marble_api.app import app

__all__ = ["app"]
Loading