Integrations API¶
Thin bridges from the patcher core into operator-graph frameworks, each gated behind the matching extra. (JAX batching and the Dask bridge are runners: see Running at scale.)
pipekit operator bridge (geopatcher.integrations.pipekit, [pipekit] extra)¶
Operator wrappers that plug a SpatialPatcher into a pipekit
Sequential / Graph pipeline:
geopatcher.integrations.pipekit.GridSampler
¶
Bases: Operator
Operator: Field → list[Patch] — yields the Patcher's patches.
Materialises the iterator into a list so downstream operators don't
need to know about lazy iteration; users who want streaming should
consume patcher.split directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
patcher
|
SpatialPatcher
|
The |
required |
Note
forbid_in_yaml = True — patcher is a runtime SpatialPatcher
(not a pipekit_ops.Operator), so pipekit's from_state cannot rebuild
it and pipekit_ops.check_pickleable cannot look inside it; the flag
makes the lint report this operator, so a closure-bearing axis
(e.g. spatial.window.Custom) is not hidden. get_config() nests the
patcher as a {"class", "config"} envelope, which
geopatcher.config.from_config rebuilds when the patcher is serialisable.
Source code in packages/geotoolz-patcher/src/geopatcher/integrations/pipekit.py
geopatcher.integrations.pipekit.ApplyToChips
¶
Bases: Operator
Operator: list[Patch] → list[Patch] — map operator over each patch.
The inner operator runs against each patch.data and the result
replaces patch.data; anchor / indices / weights are
preserved so downstream MergePatches can reconstruct the field.
When the operator declares a coupling (every geoops operator does;
a pipekit Sequential combines its steps), the call warns with
PatchReachWarning when patching changes the answer: an operator fitted
over space (a scaler, a matched filter) fits per patch or reuses one
patch's fit; a global operator (reach=None, such as a scene
percentile stretch) gives a different result per patch whatever the
overlap; and a local one with reach r pixels needs neighbouring
raster patches to overlap by at least 2 r pixels, so every pixel
lies at least r from the edge of a patch that keeps it. The check is necessary,
not sufficient: MergePatches with spatial.aggregation.OverlapAdd
still blends in edge pixels unless the window gives them zero weight.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operator
|
Operator
|
The per-chip operator (any |
required |
check_reach
|
bool
|
Warn as above. |
True
|
Source code in packages/geotoolz-patcher/src/geopatcher/integrations/pipekit.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
geopatcher.integrations.pipekit.MergePatches
¶
Bases: Operator
Operator: list[Patch] → field — wraps a spatial.aggregation.Aggregation.
Pairs with GridSampler + ApplyToChips to express split →
operator → merge as a three-step Sequential. The domain
argument is supplied at construction (commonly field.domain) so
the resulting Operator has a single positional input (the list of
patches) and slots into the linear pipeline.
On a raster domain (a RasterDomain, such as a RasterField's) the
merged array comes back as a geoarray.GeoArray on the domain's grid —
the carrier the patches went in as — with the band count the patches
carry: a per-patch
operator that turns four bands into one index gives (1, H, W),
with the source's stale per-band attrs dropped and a NaN fill.
Other outputs (a dict, a streaming zarr array, a non-georeferenced
domain) are returned as the aggregation produced them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aggregation
|
Aggregation
|
The |
required |
domain
|
Any
|
The |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
When applied, if |
Note
forbid_in_yaml = True — domain is a runtime Domain
protocol object (a grid and a shape) and isn't in
general JSON-serialisable, so the constructor cannot be
round-tripped from get_config() alone. get_config() emits a
debug record (class names + nested configs) for introspection /
logging, not for replay.
Source code in packages/geotoolz-patcher/src/geopatcher/integrations/pipekit.py
geopatcher.integrations.pipekit.PatchReachWarning
¶
Bases: UserWarning
Patching changes the answer: the patches overlap by less than the operator's spatial reach, or the operator reads the whole scene.
pipekit-train dataset (geopatcher.integrations.train, [train] extra)¶
XarrayWindowDataset: a pipekit-train TrainingDataset that samples
(input, target) windows along a dimension from lazy xarray / Zarr stores,
using the temporal stencils in geopatcher.temporal.stencils. It rides the
Equinox adapter's Grain path (shuffle, checkpoint and resume), and with
block_reader=True reads coalesced blocks with window shuffling and
multi-host sharding. It moved here from pipekit_train.xarray_window, so
pipekit does not depend on geopatcher.
geopatcher.integrations.train.XarrayWindowDataset
¶
Bases: TrainingDataset
Lazy, indexable (input, target) windows sampled from a Zarr store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
dict[str, Dataset]
|
dict of lazy |
required |
stencils
|
dict[str, Any]
|
matching dict of stencils (one per source leaf). |
required |
sample_origins
|
ArrayLike | None
|
coordinate values to anchor windows on. |
None
|
sample_dim
|
str
|
dimension to sample along (default |
'time'
|
store_version
|
str
|
opaque token identifying the store contents for hashing
(Zarr |
required |
block_reader
|
bool
|
when |
False
|
buffer_size_in_bytes
|
float
|
shuffle-buffer byte budget for the block reader
(ignored unless |
10000000000.0
|
buffer_diversity
|
int
|
blocks represented in the shuffle buffer (ignored
unless |
10
|
shard_index
|
int | None
|
this host's shard for the block reader. When it and
|
None
|
shard_count
|
int | None
|
number of shards for the block reader (see
|
None
|
split_guard
|
int | None
|
origins to drop on the interior side of each split
boundary. |
None
|
seed
|
int
|
RNG seed, the standard |
0
|
split
|
Split
|
|
'train'
|
Source code in packages/geotoolz-patcher/src/geopatcher/integrations/train.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
build_batch_iter(batch_size, seed)
¶
Adapter hook (see adapters/equinox.py _BatchSource).
Returns a checkpointable Grain iterator yielding collated, batched
(X, Y) pairs via the block reader, or None to decline so the
adapter falls back to the per-example indexable path. Declines unless
block_reader=True.
Source code in packages/geotoolz-patcher/src/geopatcher/integrations/train.py
close()
¶
Release the loader thread pools held by this dataset's sources.
Each reader source lazily creates a large ThreadPoolExecutor on
first read; without an explicit close those threads are only
reclaimed by the garbage collector. This covers the per-example
source and every block-reader source build_batch_iter handed
out. Safe to call repeatedly; the pools are rebuilt on the next
read if the dataset is used again.
Source code in packages/geotoolz-patcher/src/geopatcher/integrations/train.py
with_split(split)
¶
Return a clone of this dataset restricted to split.
The clone builds its own reader sources (and, lazily, its own
loader thread pools); the parent keeps its own. Call close
on datasets you no longer iterate to release their pools.