Skip to content

Phase 6: the page of a Comune with Docker, notebooks, riuso - #41

Merged
gzileni merged 1 commit into
mainfrom
feat/fase-6-docker-ui
Nov 26, 2026
Merged

gzileni merged 1 commit into
mainfrom
feat/fase-6-docker-ui

Conversation

@gzileni

@gzileni gzileni commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Parte di #26. Closes #21.

What is in it

  • Docker: compose.yaml (name: firms-client) with firms-client-api, firms-client-ui (127.0.0.1:3005), firms-client-notebook (profile notebook, 8890), firms-client-mcp (profile mcp, 8769) and a cli (profile tools). Ports, volume and settings from .env; .env.example complete. Data in the volume at DATA_ROOT=/data.
  • MAP_KEY: only from .env (FIRMS_MAP_KEY) or a file in ./secrets mounted read-only; .dockerignore keeps .env and secrets out of the images. httpx URL logging is silenced and every error message is redacted. tests/test_demo_api.py runs the API with a fake key against a FIRMS that echoes it back, and checks the key is in no answer and no log.
  • demo/api.py (Starlette): /api/health, /api/season?year=, /api/recent?days=, /api/history, /api/trust?lat=&lon=. The numbers are firms_client.facts answers; without a key the last days are measured: false with not_measured_because: no_map_key, never 0.
  • demo/web (Next.js standalone, Bootstrap Italia and Leaflet from npm, no CDN): Italian and English, configured from env and URL (?lat=&lon=&place=&zoom=&lang=&embed=1), frame-ancestors from FIRMS_UI_FRAME_ANCESTORS. The last 7 days, each archive year with its largest fires and the land under them, a bar per year, trust at a clicked point, «Non è un'allerta» always in view, presence-only note, NASA and (when used) ESA WorldCover credits.
  • firms-mcp --http PORT --host HOST: the MCP server over streamable HTTP, for the container.
  • Notebooks (Notebooks: a national fire history and a season comparison #21), stored executed: national fire history, season comparison, how much to trust, cells for a model. make notebooks; make notebooks-offline (03, 04, no network) runs in CI.
  • CI: docker job (build, start without a key, /api/health and / must answer) and notebooks job; the check job installs the demo group (mypy covers demo/).
  • docs/riuso.md completed; README section; CHANGELOG; publiccode feature line.

Checked

  • make check (208 passed, 99.1 %), make test-core, make bench (34 of 41, no change), make faithful, make docs, make notebooks-offline; web tsc and next build.
  • docker compose build && up -d locally: page 200 with the CSP header; archives of 14 years and WorldCover of the Palermo area downloaded; season 2023 measured (268 fires, largest events "wildfire"), trust at the 2023 fire 1.0, history per year. Without a key /api/recent is not measured; with the real key (never printed) it is measured, and the key appears in no answer, no container log and not in the image.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VFEUmXwmaxtB7PF8sSP1d4

- compose.yaml (name firms-client): api, ui on 127.0.0.1:3005, notebook
  (8890) and mcp (8769) profiles, cli; Dockerfile; ports and volumes from
  .env, complete .env.example. The MAP_KEY only from .env or a mounted file,
  never in an image, a log or an answer (tested).
- demo/api.py: facts answers for the area of the Comune (season, last days
  with a MAP_KEY, per year, trust at a point); not measured is null.
- demo/web: Next.js standalone, Bootstrap Italia and Leaflet from npm,
  Italian and English, iframe frame-ancestors, «Non è un'allerta» in view.
- firms-mcp --http PORT --host HOST.
- Four notebooks (#21), executed; make notebooks, notebooks-offline in CI.
- CI: the Docker stack starts without a key and answers.
- docs/riuso.md: installing the page for a Comune.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VFEUmXwmaxtB7PF8sSP1d4
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T09:05:07.743585Z 97ae305 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97ae30569a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread demo/api.py
Comment on lines +349 to +350
mask = api.store.mask
labelled = mask.label(rows) if mask is not None else rows

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Wait for the static mask before caching recent fire classifications

When a visitor opens the page while archives are downloading, Fires.tsx requests recent data as soon as health responds, before the static mask exists. This branch then classifies untyped NRT detections without the mask, so industrial sources can appear as vegetation fires. The resulting answer remains cached for ten minutes even after the mask becomes available, and the page never requests it again during that session. Gate classification on mask readiness, or invalidate and refresh these answers when preparation completes.

Useful? React with 👍 / 👎.

setSilent(failed(h));
if (!failed(h)) {
setHealth(h);
if (h.data.state === "ready" || h.data.state === "failed") return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Continue polling until land-cover preparation finishes

On the first startup with land cover enabled, Api.prepare() sets the archive state to ready before downloading WorldCover tiles. Stopping health polling here means the page never observes land-cover readiness: its initial season and URL-point trust requests run without land data and are not refreshed when the download finishes. A visitor who leaves the page open therefore misses the promised land classifications and receives incomplete trust results until reloading or interacting again. Track land-cover readiness and refresh the affected answers when it changes.

Useful? React with 👍 / 👎.


useEffect(() => {
if (!ready || year === null) return;
ask<FireAnswer>("season", { year }).then((a) => setSeason(failed(a) ? null : a));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Discard season responses for previously selected years

If a visitor selects another year before the previous season request finishes, both callbacks can update season, and the older request can finish last. The heading and active history bar then show the newly selected year while the counts and map show a different year's fires. This is particularly plausible when requests include threaded land-cover sampling. Cancel superseded requests or guard their callbacks with an effect cleanup or request identifier before updating state.

Useful? React with 👍 / 👎.

Comment thread compose.yaml
Comment on lines +24 to +25
FIRMS_MAP_KEY: ${FIRMS_MAP_KEY:-}
FIRMS_MAP_KEY_FILE: /run/secrets/firms/${FIRMS_MAP_KEY_NAME:-map_key}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make the mounted key file usable by the MCP and CLI services

When deployment uses the documented secrets/map_key alternative and leaves FIRMS_MAP_KEY empty, only the demo API reads FIRMS_MAP_KEY_FILE. The MCP server's _map_key() and the CLI both use client.map_key_from_env(), which reads only FIRMS_MAP_KEY or the working directory's .env; that file is excluded from the image. Consequently, the MCP area tools and CLI operations requiring a key fail despite inheriting this mounted secret configuration. Resolve the file-backed key for those services as well.

Useful? React with 👍 / 👎.

@gzileni
gzileni merged commit a2fa149 into main Nov 26, 2026
8 checks passed
@gzileni
gzileni deleted the feat/fase-6-docker-ui branch November 26, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notebooks: a national fire history and a season comparison

1 participant