Skip to content
Open
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
5 changes: 3 additions & 2 deletions apps/cohorter/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# =========================
.env
.env.*
!.env.example
!/env/
/env/*
!/env/cohorter.env
*.key
*.pem
*.p12
Expand Down Expand Up @@ -50,7 +52,6 @@ __pycache__/
*$py.class
.venv/
venv/
env/
pip-wheel-metadata/
.pytest_cache/
.mypy_cache/
Expand Down
8 changes: 4 additions & 4 deletions apps/cohorter/NL2DSL/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This folder contains the **NL2DSL** service for the Cohorter application.

NL2DSL accepts a **natural-language cohort request** and uses an LLM (via **Ollama**) to translate it into a **JSON cohort DSL**. It can optionally call the **MedCAT** service for clinical concept annotation / normalization (depending on your server implementation).

This service is designed to run as part of the full stack (recommended) using the repo-root `docker-compose.yml`.
This service is designed to run as part of the full stack (recommended) using [`docker/docker-compose.yml`](../docker/docker-compose.yml).

---

Expand All @@ -19,10 +19,10 @@ This service is designed to run as part of the full stack (recommended) using th

## Run with Docker Compose (recommended)

From the **repo root**:
From `apps/cohorter/docker/`, using `env/cohorter.env`:

```bash
docker compose up --build nl2dsl
docker compose --env-file ../env/cohorter.env up --build nl2dsl
```

NL2DSL API will be available at:
Expand Down Expand Up @@ -110,7 +110,7 @@ node server.js
### Ollama not reachable
- If using Docker Compose with included Ollama: confirm `ollama` container is up
```bash
docker compose ps
docker compose --env-file ../env/cohorter.env ps
```
- Check Ollama is responding:
```bash
Expand Down
28 changes: 16 additions & 12 deletions apps/cohorter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ A lightweight cohort discovery application that combines:
- `WebAPP/`
Full application (frontend + backend) providing the UI and orchestration of the workflow.

- `docker/`: Docker Compose configuration for the full stack.

---

## Quick start (Docker Compose)
Expand All @@ -27,16 +29,18 @@ A lightweight cohort discovery application that combines:
- (Optional) GPU setup if you want Ollama GPU acceleration (depends on your host OS)

### 1) Build and start all services
From this directory:
From `apps/cohorter/`, configure [`env/cohorter.env`](env/cohorter.env), then run
Compose from `docker/`:

```bash
docker compose up --build
cd docker
docker compose --env-file ../env/cohorter.env up --build
```

Or run in background:

```bash
docker compose up --build -d
docker compose --env-file ../env/cohorter.env up --build -d
```

### 2) Access the app
Expand All @@ -49,7 +53,7 @@ docker compose up --build -d

## Configuration

### NL2DSL environment variables (via docker-compose.yml)
### NL2DSL environment variables (via docker/docker-compose.yml)

NL2DSL uses:
- `OLLAMA_URL` (default in compose: `http://ollama:11434/api/generate`)
Expand All @@ -62,13 +66,13 @@ WebAPP uses:
- `NL2DSL_URL` (default: `http://cohorter-nl2dsl:3002`)

### WebAPP random data generation (optional)
The `WebAPP/Dockerfile` supports a build arg `random` to generate random data:
Set the runtime `RANDOM_DATA` variable to generate random data:

```bash
WEBAPP_RANDOM=true docker compose up --build
RANDOM_DATA=true docker compose --env-file ../env/cohorter.env up --build
```

(If you don’t need random data generation, keep it `false`.)
Set `RANDOM_DATA=false` in `env/cohorter.env` to disable random data generation.

---

Expand All @@ -86,28 +90,28 @@ Each folder contains its own `Dockerfile` and scripts.
## Notes on models and licensing

- MedCAT model packs and any potentially sensitive data **must not** be committed to the repository.
- Ollama models are stored in a Docker named volume by default (`ollama:` in `docker-compose.yml`) so they persist across restarts.
- Ollama models are stored in a Docker named volume by default (`ollama:` in `docker/docker-compose.yml`) so they persist across restarts.

---

## Troubleshooting

### Rebuild everything cleanly
```bash
docker compose down
docker compose up --build
docker compose --env-file ../env/cohorter.env down
docker compose --env-file ../env/cohorter.env up --build
```

### Remove Ollama downloaded models (if needed)
This deletes the named volume that stores Ollama models:

```bash
docker compose down -v
docker compose --env-file ../env/cohorter.env down -v
```

### Check logs
```bash
docker compose logs -f
docker compose --env-file ../env/cohorter.env logs -f
```

---
Expand Down
8 changes: 4 additions & 4 deletions apps/cohorter/WebAPP/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This webapp is a cohort app for users to obtain the number of patients satifying

Other runtime dependencies include [ECharts](https://echarts.apache.org/en/index.html) for charts and [popper.js](https://popper.js.org/) for tooltips.

A GitHub Packages token with `read:packages` scope is required to install `@cogstack/frontend-common-react`. Set it in a `.env` file at the `apps/cohorter/` root (see `.env.example`) or export it in your shell:
A GitHub Packages token with `read:packages` scope is required to install `@cogstack/frontend-common-react`. Set it in [`env/cohorter.env`](../env/cohorter.env) for Compose or export it in your shell:

```bash
export NPM_TOKEN=ghp_your_token_here
Expand Down Expand Up @@ -44,7 +44,7 @@ There is a script `gen_random_data.js` in `server/data/` folder to generate the

Please make sure to have the six data files ready in the `server/data/` folder before starting the server. To start the server, in the app folder run `cd server && npm install && npm run start`.

The recommended way to run the full stack (webapp + NL2DSL + MedCAT + Ollama) is via `docker-compose` from the `apps/cohorter/` root — see the root-level README and `.env.example` for details. The `NPM_TOKEN` is passed as a BuildKit secret; set it in the `.env` file before building.
The recommended way to run the full stack (webapp + NL2DSL + MedCAT + Ollama) uses [`docker/docker-compose.yml`](../docker/docker-compose.yml) from `apps/cohorter/docker/` — see the app-root README and [`env/cohorter.env`](../env/cohorter.env) for details. The `NPM_TOKEN` is passed as a BuildKit secret.

### Environment variables

Expand Down Expand Up @@ -92,10 +92,10 @@ In Kubernetes these are set as env vars on the webapp container (via helm `cogst

### Run using Docker with random data

Set `RANDOM_DATA=true` in your `.env` file (or leave it unset — it defaults to `true`), then from the `apps/cohorter/` root:
Set `RANDOM_DATA=true` in `env/cohorter.env` (or leave it unset — it defaults to `true`), then from `apps/cohorter/docker/`:

```bash
docker compose up --build
docker compose --env-file ../env/cohorter.env up --build
```

The webapp will be available at `http://localhost:3000`.
Expand Down
8 changes: 2 additions & 6 deletions apps/cohorter/WebAPP/client-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ It keeps the existing Alpine-style template/data model behaviour, while using Re

## Requirements

- Node.js 18+
- Node.js 20.12+
- npm
- A GitHub Packages token with `read:packages` scope (to install `@cogstack/frontend-common-react`)
- Cohorter backend server running at `http://localhost:3000` (proxied automatically in dev)

## Environment variables

A single `.env` file at the **`apps/cohorter/` root** (one level up from `WebAPP/`) is shared between Vite and `docker-compose`. Copy `.env.example` there and fill in values:

```bash
cp ../../.env.example ../../.env
```
Configure [`apps/cohorter/env/cohorter.env`](../../env/cohorter.env), shared by Vite and Docker Compose.

| Variable | Required | Description |
|---|---|---|
Expand Down
11 changes: 6 additions & 5 deletions apps/cohorter/WebAPP/client-react/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { existsSync } from 'node:fs';
import { loadEnvFile } from 'node:process';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// Express server port (same origin in production; proxied in dev)
const API_ORIGIN = 'http://localhost:3000';

// Point Vite at the apps/cohorter/ root so that it reads the same .env
// as docker-compose, eliminating the need for a separate client-react/.env.
// Both `npm run dev` (Vite) and `docker-compose build` resolve vars from one file.
const ENV_DIR = '../../';
// Share the named environment file with Compose; image builds can omit it.
const ENV_FILE = new URL('../../env/cohorter.env', import.meta.url);
if (existsSync(ENV_FILE)) loadEnvFile(ENV_FILE);

export default defineConfig({
plugins: [react()],
envDir: ENV_DIR,
envDir: false,

build: {
outDir: 'dist',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: cohorter

services:
ollama:
image: ollama/ollama:latest
Expand Down Expand Up @@ -38,7 +40,7 @@ services:

nl2dsl:
build:
context: ./NL2DSL
context: ../NL2DSL
container_name: cohorter-nl2dsl
ports:
- "3002:3002"
Expand All @@ -54,7 +56,7 @@ services:

webapp:
build:
context: ./WebAPP
context: ../WebAPP
secrets:
- npm_token
args:
Expand Down Expand Up @@ -84,7 +86,7 @@ services:
# Mount your data directory here. It should contain either:
# - snomed_terms_data.tar.gz (will be auto-extracted on startup), or
# - pre-extracted files: snomed_terms.json (SNOMED term lookup by Concept Unique Identifier) and cui_pt2ch.json (SNOMED CT ontology hierachy map).
- ./WebAPP/server/data:/usr/src/app/server/data
- ../WebAPP/server/data:/usr/src/app/server/data
depends_on:
- medcat
- nl2dsl
Expand Down
11 changes: 3 additions & 8 deletions apps/cohorter/.env.example → apps/cohorter/env/cohorter.env
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# Single env file for cogstack-cohorter.
# Copy to .env and fill in values before running docker-compose or npm run dev.
# .env is gitignored — never commit it.
#
# This file is read by:
# • docker-compose — variable substitution for build args and runtime env
# • Vite dev server — VITE_* vars picked up via envDir in vite.config.js
# Shared Cohorter configuration for Docker Compose and the Vite dev server.
# Run from docker/: docker compose --env-file ../env/cohorter.env up --build

# ── Required ─────────────────────────────────────────────────────────────────

# GitHub Packages token with read:packages scope.
# Used as a BuildKit secret at image build time to install @cogstack/frontend-common-react.
# Also needed locally for `npm install` in WebAPP/client-react/ (export NPM_TOKEN in your shell,
# or ensure it is set here so docker-compose can pass it through).
NPM_TOKEN=ghp_your_token_here
NPM_TOKEN=

# ── OAuth2 proxy paths (Vite build-time, baked into the client bundle) ───────
# Only override if your deployment uses non-standard oauth2-proxy routes.
Expand Down
80 changes: 0 additions & 80 deletions apps/jupyter-hub/.github/workflows/helm-smoke-test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion apps/jupyter-hub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Run local smoke checks for Helm/Kubernetes manifests:
bash scripts/helm_k8s_smoke_test.sh
```

CI also runs this via [`.github/workflows/helm-smoke-test.yml`](./.github/workflows/helm-smoke-test.yml) for changes affecting chart/env/config/security files.
CI chart validation lives in the shared [Helm workflow](../../.github/workflows/build_helm_charts.yml).

## Access and account control

Expand Down
Loading
Loading