Skip to content

FAO delivery path is point/DataFrame-based — won't carry rusty_bucket's pooled draws #45

Closed

Description

@Polichinel

Problem

The unfao delivery manager (views_postprocessing/unfao/managers/unfao.py) is built around point forecasts:

  • _read_forecast_data (~L62-100) downloads a single parquet DataFrame from Appwrite and wraps it in PGMDataset (pandas).
  • _append_metadata (~L112-122) joins GAUL metadata onto that DataFrame.
  • _save (~L206-223) writes pred_*_best / pred_*_prob point columns.

rusty_bucket (views-models#143) is the opposite by design: a PredictionFrameEnsembleManager + aggregation: concat ensemble that ships the full pooled posterior draws (~1024/cell, Track A y_pred.npy of shape (N, S)) uncollapsed, so the principled MAP/HDI collapse happens once downstream in views_frames_summarize.

So the current FAO delivery path would not carry rusty_bucket's draws — it expects a point DataFrame with _best/_prob columns, not (N, S) draw arrays. This is the downstream half of the views-models#143 contract: "the FAO delivery path must not collapse them."

Scope

  • Adapt the unfao delivery to read/carry the pooled draws (frames / (N, S) arrays + identifiers) for rusty_bucket, delivering them uncollapsed.
  • Keep the metadata enrichment (GaulLookupEnricher) and validation working on the frames/draws path.
  • Decide the delivery artifact to FAO (raw draws vs the views_frames_summarize collapse output).

Not blocking yet

rusty_bucket's constituent models are still being tuned (views-models#143), so this is track-and-scope. It must land before rusty_bucket goes live.

Refs

  • views-models#143 (rusty_bucket + the downstream draw-preservation contract)
  • views_postprocessing/unfao/managers/unfao.py (_read_forecast_data, _append_metadata, _save)
  • Related: C-40 in the register (the manager's pipeline-core coupling), which any rework here should keep in mind.

Activity

  1. Polichinel commented on Jun 24, 2026

    @Polichinel
    CollaboratorAuthor

    Cross-repo note from the views-faoapi side — this issue is the keystone for faoapi going frame-native.

    Confirmed end-to-end: unfao/managers/unfao.py _save → to_parquet() on the object-dtype DataFrame is exactly where the nested-array-sample parquet that faoapi consumes is born. Downstream, faoapi does the inverse dance — pd.read_parquet → _convert_to_arrays (decode each object-dtype cell back into an np.ndarray) → (N_time, N_entity, S) tensor (views-faoapi data/handlers.py ~234, ~467–516). So the object-dtype round-trip is pure overhead on both ends.

    Suggested solution shape (so it unblocks the consumer cleanly):

    • Emit a native views-frames frame carrying the full (N, S) pooled draws uncollapsed (as you note for rusty_bucket), and let the principled MAP/HDI collapse happen once in faoapi via views_frames_summarize (tower_point/hdi_tower — see views-faoapi#89).
    • Use the arrow single-file form (views_frames.io.arrow), not the npz multi-file directory — Appwrite buckets are file-oriented (one blob per artifact).
    • Carry the 9 GAUL metadata columns in the frame header/sidecar, not as DataFrame cells.

    This is the producer half of the wire-format change; the faoapi consumer half + the ADR-046 amendment are tracked in views-faoapi (new issue, linked). Resolving this is what actually lets faoapi retire its parquet decode.

  2. Polichinel commented on Jun 27, 2026

    @Polichinel
    CollaboratorAuthor

    Sharpened by the samples/uncertainty requirement (2026-06-27). The reason this issue matters is now concrete: the delivery is moving from point estimates to predictions-with-uncertainty (S samples/cell). The two representations diverge exactly here:

    • views-frames PredictionFrame = native contiguous (N, S) float32, sample axis always explicit (point is just S=1).
    • pandas PGMDataset = object-dtype list-in-cell (each of N cells holds a length-S numpy array; _convert_to_arrays in pipeline-core data/handlers.py).

    The object-dtype cost scales ~linearly with S — memory blow-up (pipeline-core's own OOM #181/#189, ~18 GB), encode/decode tax at every parquet/API boundary (faoapi's inverse decode, already noted on this issue), and a silent np.resize pad on mismatched sample counts. At S=1 invisible; at S≈1000 it dominates.

    So this issue is the producer half of carrying uncertainty: emit (N, S) draws uncollapsed as a native arrow frame rather than object-dtype parquet. Gated by C-40 (the inherited pandas container) + rusty_bucket (#143). Register C-40 updated with this priority + the concrete pipeline-core gate (#186/#207/#161/#159/#211).

  3. Polichinel commented on Jun 28, 2026

    @Polichinel
    CollaboratorAuthor

    Migration backlog created (2026-06-28): epic #85. The pandas→views-frames map for views-postprocessing is now sequenced as epic #85 ("Push pandas to the seams"), stories #86–#92, tracking #93.

    This issue (#45) is the gate + consumer half for S6 (#91) — the forecast outbound to_parquet → views_frames.io.arrow sample-frame wire, the step that actually ships (N,S) to FAO. The unilateral arc S1–S3 (#86/#87/#88) makes vpp's interior carry the draws as a PredictionFrame first, so by the time the wire cutover lands the producer side is already built + parity-tested.

  4. Polichinel commented on Jul 2, 2026

    @Polichinel
    CollaboratorAuthor

    Wire contract posted — this issue's scope is now bounded. Contract of record: views-platform/views-models#149 (comment: Sampled-Forecast Wire Contract v1, 2026-07-03); producer leg: views-platform/views-pipeline-core#269.

    vpp's obligations under the contract:

    • Hop A consumer (source adapter, extends S3 — forecast convert-at-the-door (internal PredictionFrame) #88): read the Track A archive (zip: y_pred.npy (N,S) + identifiers.npz + metadata.json) per (target, month) shard, manifest-gated, → interior per-target PredictionFrame via from_arrays. Validate payload-vs-header consistency at the door.
    • Hop B producer (sink adapter, S6 — forecast outbound → arrow sample-frame wire (ships (N,S) to FAO) #91): emit one views_frames.io.arrow file per (target, month) to unfao_bucket, §2 header embedded.
    • GAUL sidecar (§5): the 9 columns move to a gid-keyed sidecar (one per run) — faoapi already consumes them per-gid (verified); gid-set identity enforced by the existing coverage/identity invariants.
    • The S1 — Delete the retired delivery path; refuse an incomplete config #149 no-collapse boundary is named: vpp delivery/draws.py (§6) — 2-D, S==header, S≥S_min, global non-degeneracy (per-row zero variance explicitly legal). New invariant, sibling of coverage/identity/observed_range/provenance.
    • Historical artifact: unchanged (pandas parquet) in v1.

    Target vocabulary decided: lr_ged_sb/ns/os (models#146).

  5. Polichinel commented on Jul 5, 2026

    @Polichinel
    CollaboratorAuthor

    Status escalation (2026-07-05): this issue is now the confirmed blocker C of views-models#230 — the FAO walking skeleton (publish the baseline rusty_bucket forecast end-to-end to the live FAO API). The "not blocking yet" framing no longer holds: A (Appwrite collection ID) and B (run rusty_bucket) are ops steps, but with the current point-shaped _save (pred_*_best/_prob, unfao.py:298,309,316) a sample-less artifact would land in unfao_bucket, and views-faoapi's HDI/MAP forecast product cannot serve it.

    Decision fork recorded on views-models#230: minimal (pass the (N,S) sample columns through in the existing nested-parquet encoding — unilateral here, unblocks the skeleton; encoding retired later by #91/S6) vs full (the #91 arrow wire cutover, gated on #88 + vpp#222; also closes views-faoapi#100).

  6. Polichinel commented on Jul 15, 2026

    @Polichinel
    CollaboratorAuthor

    Contract ADOPTED as ADR-013 (views-postprocessing/docs/ADRs/013_sampled_forecast_wire_contract.md); see the adoption comment on views-platform/views-models#149 (2026-07-15). This issue's requirement — carry rusty_bucket's pooled draws uncollapsed — is now contractually guaranteed end-to-end: Hop-A archives preserve (N,S) verbatim, the §6 no-collapse boundary (delivery/draws.py, this repo) fails loud before any FAO-facing upload, and faoapi ingests + asserts on the same header. vpp's build legs: draws.py (unblocked now), the source adapter (Track-A archive → PredictionFrame), the sink adapter (#91), the sidecar, and the legacy type-guard (§11.4 — before pipeline-core#269's first upload).

  7. Polichinel commented on Jul 19, 2026

    @Polichinel
    CollaboratorAuthor

    Delivery plan exists: epic #105 (ADR-013 Hop-B sink leg) carries this issue's scope — pooled (N,S) draws travel uncollapsed to unfao_bucket as per-month arrow shards + sidecar + run manifest, §6 no-collapse gate wired before upload, documents under the faoapi-visible name="un_fao" (fixing the invisibility this path always had). This issue's open decision (raw draws vs summarized) is answered by the adopted contract: raw draws on the wire; MAP/HDI computed at the faoapi edge, never stored. Stays open as the semantic parent; closes at #113 (S8) when the sink is fixture-proven.

    🤖 Generated with Claude Code

  8. Polichinel commented on Jul 20, 2026

    @Polichinel
    CollaboratorAuthor

    Delivered by epic #105 (2026-07-20). The FAO delivery now carries pooled (N,S) draws uncollapsed end to end in fixture-proven code: verified Track-A inbound → §6 no-collapse gate → per-(target,month) arrow shards → GAUL sidecar (+gid parity) → run-manifest commit marker → all documents under the faoapi-visible name="un_fao" (the invisibility fix). This issue's open decision is answered by ADR-013: raw draws on the wire; MAP/HDI computed at the faoapi edge, never stored. Live enablement is interlocked (UPLOAD_ENABLED=False) pending faoapi C-161. Closing as delivered.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions