Skip to content

refactor(collection): group from_stac target-grid params into a Grid dataclass #955

Description

@MAfarrag

Context

DatasetCollection.from_stac carried 14 parameters, five of which (like, crs, resolution, bounds, anchor)
describe one thing — the target output grid — with runtime-enforced invariants (like xor the trio; the trio is
all-or-nothing). Same class of too-many-arguments smell tracked for to_cog in #757 (python:S107).

Problem / Current Behaviour

The five loose kwargs bloat the signature and scatter validation inside _resolve_target_grid.

Affected locations

File Symbol Notes
src/pyramids/dataset/grid.py Grid (new) frozen dataclass + __post_init__ validation
src/pyramids/dataset/collection.py DatasetCollection.from_stac 5 kwargs -> grid: Grid | None
src/pyramids/dataset/_stac.py from_stac, _resolve_target_grid take a Grid

Proposed Solution

from pyramids.dataset import Grid
DatasetCollection.from_stac(items, "B04", grid=Grid(crs=32633, resolution=10, bounds=(...)))

Drops from_stac from 14 to 10 params; mirrors odc.stac.load's geobox= grouping.

Out of Scope

from_point (tracked separately); other constructors.

Effort Estimate

Size: S — new dataclass + signature change + test migration.

Definition of Done

  • Grid dataclass with mode-invariant validation, exported from pyramids.dataset
  • from_stac takes grid=Grid(...) (breaking; no alias)
  • tests + docs updated

Relates to #757 (same S107 parameter-count reduction). Implemented in PR #951.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeature collectionfeature collection classstacSTAC catalogs: signers, asset loading, VRT mosaics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions