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
30 changes: 15 additions & 15 deletions deploy/seed/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# One-shot image for the sample-data seed script.
#
# Re-built only when requirements.txt changes — the script itself is
# bind-mounted at runtime so iterating on seed.py doesn't trigger an
# image rebuild.
# Installs deps + the seeder from pyproject.toml (single source of truth).
# The script is bind-mounted at runtime (see docker-compose.yml seed-sample)
# so iterating on seed.py doesn't require a rebuild; rebuild when
# pyproject.toml or the packaged sources change.

# Pinned to 3.12 to match src/ingestion/tools/toolbox/Dockerfile (the
# deploy dbt-run image) — apply-ch-migrations.sh runs dbt here, and
# dbt-clickhouse is validated against 3.12 on that image.
FROM python:3.12-slim
# Python 3.13 to match this seeder's pyproject (ruff target-version /
# mypy python_version = 3.13).
FROM python:3.13-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
Expand All @@ -25,16 +25,16 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends curl bash \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install -r requirements.txt

# Source is bind-mounted at runtime (see docker-compose.yml seed-sample
# service). The COPY lines below are a fallback for `docker build &&
# docker run` without a volume — exercised only by ad-hoc inspection,
# so the `generators/` package must come along or `silver.py`'s
# `from generators import ...` fails at import time.
# Source is copied before the install so the build backend can package the
# flat modules + generators/. At runtime the source is bind-mounted (see
# docker-compose.yml seed-sample service); these COPY lines are also the
# fallback for `docker build && docker run` without a volume — exercised only
# by ad-hoc inspection, so the `generators/` package must come along or
# `silver.py`'s `from generators import ...` fails at import time.
COPY pyproject.toml .
COPY *.py ./
COPY generators ./generators/
RUN pip install .

ENTRYPOINT ["python", "seed.py"]
CMD ["all"]
10 changes: 4 additions & 6 deletions deploy/seed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ The stack must be up first (`./dev-compose.sh up`). Then:
```bash
cd insight/deploy/seed
python3 -m venv .venv # one-time
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/pip install -e '.[dev]'

.venv/bin/ruff check .
.venv/bin/mypy .
```

Pinned dep versions live in `requirements.txt` / `requirements-dev.txt`.
Re-resolve via `.venv/bin/pip install --upgrade <pkgs>` + `pip freeze`.
Deps live in `pyproject.toml`: `[project.dependencies]` for runtime,
`[project.optional-dependencies].dev` for the tooling (ruff, mypy, stubs).

## Layout

Expand All @@ -39,6 +39,4 @@ Re-resolve via `.venv/bin/pip install --upgrade <pkgs>` + `pip freeze`.
| `identity.py` | MariaDB seed: persons, org_chart, account_person_map. |
| `silver.py` | ClickHouse silver seed — Phase 2 placeholder. |
| `Dockerfile` | One-shot image for the compose `seed-sample` service. |
| `requirements.txt` | Pinned runtime deps. |
| `requirements-dev.txt` | Pinned dev deps (ruff, mypy, stubs). |
| `pyproject.toml` | ruff + mypy config. |
| `pyproject.toml` | Package metadata, deps (runtime + dev), ruff + mypy config. |
37 changes: 35 additions & 2 deletions deploy/seed/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Tool config for the Insight sample-data seeder.
# Lives next to the code so `ruff check .` and `mypy .` work from the dir.
# Package metadata, dependencies, and tool config for the Insight
# sample-data seeder. Lives next to the code so `ruff check .` and `mypy .`
# work from the dir, and `pip install .` builds the flat module + generators
# package straight from here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add cf-studio-path configuration.

As per coding guidelines, TOML configuration files must set cf-studio-path to .cf-studio.

🛠️ Proposed fix
 # package straight from here.
 
+cf-studio-path = ".cf-studio"
+
 [build-system]
 requires = ["setuptools>=61"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# package straight from here.
cf-studio-path = ".cf-studio"
[build-system]
requires = ["setuptools>=61"]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@deploy/seed/pyproject.toml` at line 5, Add the required cf-studio-path
configuration to the TOML project settings in pyproject.toml, setting its value
to .cf-studio as specified by the coding guidelines.

Source: Coding guidelines

[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"

[project]
name = "insight-seed"
version = "0.1.0"
description = "Insight sample-data seeder for the local docker-compose stack."
requires-python = ">=3.13"
dependencies = [
"PyMySQL==1.2.0",
"clickhouse-connect==1.2.0",
# Unpinned to match src/ingestion/tools/toolbox/Dockerfile. dbt-core pulls
# in PyYAML, which apply-ch-migrations.sh's profiles.yml generator imports.
"dbt-clickhouse",
]

[project.optional-dependencies]
dev = [
"mypy==2.1.0",
"ruff==0.15.16",
"types-PyMySQL==1.1.0.20260518",
]

# Flat layout: top-level modules plus the generators/ package.
[tool.setuptools]
py-modules = ["seed", "silver", "identity", "profiles"]

[tool.setuptools.packages.find]
include = ["generators*"]

[tool.ruff]
line-length = 100
Expand Down
4 changes: 0 additions & 4 deletions deploy/seed/requirements-dev.txt

This file was deleted.

7 changes: 0 additions & 7 deletions deploy/seed/requirements.txt

This file was deleted.

Loading