Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
OAC_BACKEND=sqlite
OAC_DB_PATH=/data/oacapi.db
API_PORT=5000
API_WORKERS=1
API_THREADS=2
AC_PATH=./astrocats
INGEST_AC_PATH=/root/astrocats/astrocats
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ before_install:
install:
- conda update setuptools
- conda config --add channels conda-forge
- conda install --yes astrocats astropy flask numpy six
- conda install --yes astropy flask numpy six
- pip install flask_compress flask_restful

script:
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

COPY . /app

EXPOSE 5000

CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "1", "--threads", "2", "wsgi:app"]
17 changes: 17 additions & 0 deletions Dockerfile.ingest
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

COPY . /app

CMD ["python", "scripts/ingest_static_catalogs.py"]
13 changes: 13 additions & 0 deletions Dockerfile.mcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.11-slim

WORKDIR /app

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

COPY . /app

CMD ["python", "mcp_server.py"]
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,47 @@ https://api.astrocats.space/catalog/photometry/time+band+magnitude?ra=21:23:32.1
#### Return the instruments used to produce spectra within a 5° of a given coordinate, in CSV format

https://api.astrocats.space/catalog/spectra/instrument?ra=21:23:32.16&dec=-53:01:36.08&radius=18000&format=csv

## Modern backend and deployment

This project now supports a modern SQLite-backed runtime that preserves the API
signature and response semantics while reducing memory pressure on constrained
nodes. The API does not interact with external services.

### Runtime modes

Use environment variables to choose the backend:

- `OAC_BACKEND=sqlite` (default): query a pre-built SQLite snapshot.
- `OAC_BACKEND=legacy`: load original JSON files directly from astrocatalog
repositories.

For SQLite mode:

- `OAC_DB_PATH` points to the sqlite file (default `/data/oacapi.db`).
- SQLite stores summary/index data plus event file pointers only. Full event JSON
is loaded directly from the existing catalog `output/json` files, avoiding a
second copy of large event data.
- Build the sqlite snapshot using:

```bash
python scripts/ingest_static_catalogs.py --db-path /data/oacapi.db --ac-path /root/astrocats/astrocats
```

### MCP layer

An MCP server is provided in `mcp_server.py` and exposes:

- `query_api`: executes the same route/query semantics as the HTTP API.
- `health`: service health probe.

### Docker Compose deployment

Use compose to run API + MCP and optionally ingest:

```bash
docker compose --profile ingest run --rm ingest
docker compose up --build -d api mcp
```

See `docs/deployment-compose.md` for full instructions.
Loading