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
105 changes: 105 additions & 0 deletions .github/workflows/service-noise-generation-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: noise-generation-service

on:
push:
branches: ["master"]
paths:
- "services/noise-generation-service/**"
pull_request:
branches: ["master"]
paths:
- "services/noise-generation-service/**"

defaults:
run:
working-directory: services/noise-generation-service

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync
- name: Lint
run: make lint

test:
name: Test
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync
- name: Run tests
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: services/noise-generation-service/coverage.xml
flags: noise-generation-service
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
if: always()

generate-openapi:
name: Generate OpenAPI Spec
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync
- name: Generate OpenAPI spec
run: make generate-openapi
- name: Upload OpenAPI spec
uses: actions/upload-artifact@v4
with:
name: openapi-spec-noise-generation-service
path: services/noise-generation-service/noise-generation-service.openapi.json

build:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: generate-openapi
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/noise-generation-service
tags: |
type=sha,prefix=sha-
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: services/noise-generation-service
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![jsonpath-mapper-service CI](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-jsonpath-mapper-service.yml/badge.svg)](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-jsonpath-mapper-service.yml)
[![sql-assessment-service CI](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-sql-assessment-service.yml/badge.svg)](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-sql-assessment-service.yml)
[![fermentaladin-service CI](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-fermentaladin-service.yml/badge.svg)](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-fermentaladin-service.yml)
[![noise-generation-service CI](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-noise-generation-service.yml/badge.svg)](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-noise-generation-service.yml)

## Services

Expand All @@ -14,6 +15,7 @@
| [jsonpath-mapper-service](services/jsonpath-mapper-service/README.md) | TypeScript | [![CI](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-jsonpath-mapper-service.yml/badge.svg)](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-jsonpath-mapper-service.yml) | [![codecov](https://codecov.io/gh/HTW-ALADIN/ALADIN-Services/graph/badge.svg?flag=jsonpath-mapper-service)](https://codecov.io/gh/HTW-ALADIN/ALADIN-Services?flags[0]=jsonpath-mapper-service) | JSONPath Mapper — JSON-to-JSON transformation utility exposed as a Fastify HTTP API |
| [sql-assessment-service](services/sql-assessment-service/README.md) | TypeScript | [![CI](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-sql-assessment-service.yml/badge.svg)](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-sql-assessment-service.yml) | [![codecov](https://codecov.io/gh/HTW-ALADIN/ALADIN-Services/graph/badge.svg?flag=sql-assessment-service)](https://codecov.io/gh/HTW-ALADIN/ALADIN-Services?flags[0]=sql-assessment-service) | SQL Assessment — schema analysis, SQL task generation, and query grading |
| [fermentaladin-service](services/fermentaladin-service/README.md) | Python | [![CI](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-fermentaladin-service.yml/badge.svg)](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-fermentaladin-service.yml) | — | Bioreactor fermentation simulation — ODE-based multi-phase kinetic model exposed as a FastAPI HTTP service |
| [noise-generation-service](services/noise-generation-service/README.md) | Python | [![CI](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-noise-generation-service.yml/badge.svg)](https://github.com/HTW-ALADIN/ALADIN-Services/actions/workflows/service-noise-generation-service.yml) | [![codecov](https://codecov.io/gh/HTW-ALADIN/ALADIN-Services/graph/badge.svg?flag=noise-generation-service)](https://codecov.io/gh/HTW-ALADIN/ALADIN-Services?flags[0]=noise-generation-service) | Noise Generation — deterministic procedural scalar fields and contour-style plots exposed as FastAPI and CLI |

## For Developers:

Expand Down
17 changes: 17 additions & 0 deletions services/noise-generation-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.12-slim-trixie

RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*

ADD https://astral.sh/uv/install.sh /uv-installer.sh
RUN sh /uv-installer.sh && rm /uv-installer.sh

ENV PATH="/root/.local/bin/:$PATH"

COPY . /app
WORKDIR /app
RUN uv sync --locked --no-dev

EXPOSE 8001

CMD ["uv", "run", "--no-sync", "uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8001", "--app-dir", "src"]
31 changes: 31 additions & 0 deletions services/noise-generation-service/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
IMAGE_NAME := noise-generation-service
OPENAPI_OUT := noise-generation-service.openapi.json
PORT ?= 8001

.PHONY: prep build test lint start clean docker-build generate-openapi

prep:
uv sync

build:
@echo "No build step required for Python"

test:
uv run pytest --cov=src --cov-report=xml --cov-report=term-missing

lint:
uv run ruff check src/ test/
uv run ruff format --check src/ test/

start:
uv run uvicorn api:app --reload --port $(PORT) --app-dir src

clean:
rm -rf .coverage coverage.xml htmlcov/ .pytest_cache $(OPENAPI_OUT)
find . -type d -name __pycache__ -exec rm -rf {} +

docker-build:
docker build -t $(IMAGE_NAME) .

generate-openapi:
uv run python src/generate_openapi.py
91 changes: 91 additions & 0 deletions services/noise-generation-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Noise Generation Service

HTTP and CLI wrapper for deterministic procedural noise fields used to create practice data for geo-informatics and geostatistical interpolation exercises.

The service exposes scalar noise grids and contour-style SVG plots. It uses `pyfastnoiselite`, a Python wrapper around FastNoiseLite, through the adapter in `src/noise_generation_service/generator.py`.

## API

Start the service:

```sh
make start
```

The API listens on port `8001` by default.

OpenAPI docs:

```text
http://localhost:8001/docs
```

Endpoints:

| Method | Path | Description |
| --- | --- | --- |
| `GET` | `/health` | Liveness probe |
| `POST` | `/noise/grid` | Return a deterministic 2D scalar grid as JSON |
| `POST` | `/noise/contour.svg` | Return a contour-style SVG plot |

Example request:

```json
{
"width": 80,
"height": 80,
"seed": 42,
"scale": 24.0,
"octaves": 5,
"persistence": 0.5,
"lacunarity": 2.0,
"levels": 10,
"samplePoints": 8
}
```

## CLI

The CLI mirrors the API outputs:

```sh
uv run noise-generation grid --width 80 --height 80 --seed 42 --output grid.json
uv run noise-generation contour --width 80 --height 80 --seed 42 --output contour.svg
```

Without `--output`, the generated JSON or SVG is written to stdout.

## Docker

Build:

```sh
make docker-build
```

Run:

```sh
docker run --rm -p 8001:8001 noise-generation-service
```

## Hardware Requirements

Minimal requirements for the default API limits:

| Resource | Requirement |
| --- | --- |
| CPU | 1 vCPU |
| Memory | 256 MB RAM |
| Disk | < 200 MB image/runtime overhead, excluding Docker base layers |

The default request limit is `512 x 512` grid cells. Larger grids should be guarded by deployment-level request limits or implemented as asynchronous jobs.

## Development

```sh
make prep
make lint
make test
make generate-openapi
```
Loading