Skip to content

Commit

Permalink
feat: restructure lidar API into addlidar-api package and update depe…
Browse files Browse the repository at this point in the history
…ndencies
  • Loading branch information
guilbep committed Feb 10, 2025
1 parent 1d3e9c6 commit bca8845
Show file tree
Hide file tree
Showing 25 changed files with 829 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
with:
org: epfl-cryos # your org
repo: addlidar-api # your app name, usual convention is name of your repository
build_context: '["./lidar-api"]'
build_context: '["./addlidar-api"]'
1 change: 1 addition & 0 deletions lidar-api/.gitignore → addlidar-api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__/
.Python
env/
venv/
.venv
ENV/
*.egg-info/
.installed.cfg
Expand Down
1 change: 1 addition & 0 deletions addlidar-api/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.5
17 changes: 17 additions & 0 deletions addlidar-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.12-slim

# Install uv.
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Copy the application into the container.
COPY . /app

# Install the application dependencies.
WORKDIR /app
RUN uv sync --frozen --no-cache

# Expose the application port to the host.
EXPOSE 80

# Run the application.
CMD ["/app/.venv/bin/fastapi", "run", "app/main.py", "--port", "80", "--host", "0.0.0.0", "--proxy-headers"]
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions addlidar-api/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
AddLidar API application package.
"""
File renamed without changes.
6 changes: 6 additions & 0 deletions addlidar-api/app/dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from typing import Annotated
from fastapi import Header, HTTPException

async def get_token_header(x_token: Annotated[str, Header()]):
if x_token != "fake-super-secret-token":
raise HTTPException(status_code=400, detail="X-Token header invalid")
3 changes: 3 additions & 0 deletions addlidar-api/app/internal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Internal package for admin functionalities.
"""
11 changes: 11 additions & 0 deletions addlidar-api/app/internal/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from fastapi import APIRouter, Depends
from app.dependencies import get_token_header

router = APIRouter(
dependencies=[Depends(get_token_header)],
responses={404: {"description": "Not found"}},
)

@router.get("/")
async def read_admin():
return {"message": "Admin getting schwifty"}
9 changes: 9 additions & 0 deletions addlidar-api/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from fastapi import FastAPI
from app.routers import process_point_cloud
from app.internal import admin

app = FastAPI()

# Include routers
app.include_router(process_point_cloud.router, prefix="/api")
app.include_router(admin.router, prefix="/admin", tags=["admin"])
3 changes: 3 additions & 0 deletions addlidar-api/app/routers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Router package for API endpoints.
"""
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 4 additions & 7 deletions lidar-api/docker-compose.yml → addlidar-api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
version: '3.8'

services:
lidar-api:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"
volumes:
- ./data:/data
- "8000:80"
environment:
- PORT=80
- ENV=development
depends_on:
- db
volumes:
- ./data:/data

db:
image: postgres:latest
Expand Down
18 changes: 18 additions & 0 deletions addlidar-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[project]
name = "addlidar-api"
version = "0.1.0"
description = "FastAPI application for LiDAR data processing"
readme = "README.md"
requires-python = ">=3.11.5"
dependencies = [
"docker>=7.1.0",
"fastapi[standard]>=0.115.8",
"httpx>=0.28.1",
"pydantic>=2.10.6",
"python-dotenv>=1.0.1",
"uvicorn>=0.34.0",
]

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
752 changes: 752 additions & 0 deletions addlidar-api/uv.lock

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions lidar-api/Dockerfile

This file was deleted.

32 changes: 0 additions & 32 deletions lidar-api/kubernetes/deployment.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions lidar-api/kubernetes/service.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions lidar-api/requirements.txt

This file was deleted.

23 changes: 0 additions & 23 deletions lidar-api/src/api/models.py

This file was deleted.

10 changes: 0 additions & 10 deletions lidar-api/src/main.py

This file was deleted.

0 comments on commit bca8845

Please sign in to comment.