rs_workflows/dpr_flow.md¶
DPR flow implementation
clean_paths(paths, logger)
¶
Delete directories or files listed in paths, logging outcomes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list[str]
|
List of filesystem paths to remove. |
required |
logger
|
Prefect logger for informational messages. |
required |
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
compute_eopf_origin_datetime(env, input_products, *, items=None)
¶
Compute the maximum eopf:origin_datetime across all input products.
For each input product, this function retrieves the corresponding item
from the catalog using its item ID and collection ID, extracts the
eopf:origin_datetime property, and returns the latest (maximum)
datetime value found.
If an item cannot be retrieved from the catalog, processing fails. Already retrieved items can be supplied to avoid duplicate catalog requests.
Parameters¶
env : object Execution environment object used to serialize and pass context to the catalog flow. input_products : Iterable[FlowInputProduct] Input products with item IDs and collection names. items : list[Item] | None Previously retrieved input STAC items, if available.
Returns¶
str
ISO 8601 string representing the maximum eopf:origin_datetime
found among all retrieved items. Raises ValueError if no origin
datetimes are found.
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
create_stac_item(eopf_origin_datetime, eopf_feature, s3_data_location, product_name, dpr_processor, zarr_zip_href=None)
¶
Create a list of STAC Items from EOPF features and processing payload metadata.
This function builds STAC Items compliant with EOPF constraints by: - Injecting EOPF-specific properties into each feature - Attaching output product assets - Propagating origin datetimes from input products
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eopf_features
|
list[dict]
|
List of GeoJSON-like feature dictionaries. |
required |
s3_data_location
|
str
|
Base S3 path where output products are stored. |
required |
product_name
|
str
|
Product name |
required |
dpr_processor
|
str
|
DPR processor name |
required |
zarr_zip_href
|
str | None
|
S3 path of the associated .zarr.zip product, if any. When set, an additional asset is added to the item. |
None
|
Returns:
| Type | Description |
|---|---|
Item
|
list[Item]: List of constructed STAC Item objects. |
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 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 | |
find_zarr_stores(files, base_path)
¶
Find the Zarr product stores located in an output product path.
The candidate store directories are derived from the listed file URIs, and the
zarr library is used to identify which of them are Zarr groups, whatever their
Zarr format (see rs_workflows.utils.zarr_utils.is_zarr_group). The supported
layouts are:
base_path (the output path is itself the product store)
base_path/product_name
base_path/products/product_name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[str]
|
List of file URIs found under the base path. |
required |
base_path
|
str
|
The base directory URI of the output products. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[str, str]]
|
A list of tuples, where each tuple contains: - product_name (str): The name of the product store directory. - store_uri (str): The URI of the Zarr product store. |
list[tuple[str, str]]
|
If |
list[tuple[str, str]]
|
and its nested groups are ignored. Nested groups of the product stores are |
list[tuple[str, str]]
|
never returned either. |
Example
files = [ ... "/data/products/product_a/zarr.json", ... "/data/products/product_b/.zgroup", ... "/data/products/product_c/subdir/file.txt" ... ] find_zarr_stores(files, "/data/products") [('product_a', '/data/products/product_a'), ('product_b', '/data/products/product_b')]
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
find_zarr_zip(zarr_location)
¶
Return the S3 path of the <PRODUCT_NAME>.zarr.zip stored next to a Zarr product, if it exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zarr_location
|
str
|
S3 URI of the Zarr product store. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The S3 path of the zip file, or None if the zip is not present. |
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
get_input_product_items(env, input_products)
¶
Retrieve source STAC items, excluding auxiliary inputs, once per update.
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
run_processor(env, processor, payload, cluster_info, s3_payload_run, input_products)
async
¶
Run the DPR processor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
FlowEnvArgs
|
Prefect flow environment |
required |
processor
|
str
|
DPR processor name |
required |
s3_payload_run
|
str
|
S3 bucket location of the output final DPR payload file. |
required |
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | |
s3_list(s3_prefix)
¶
List all S3 objects under a prefix without downloading.
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
update_eopf_assets(env, input_products, payload, dpr_processor)
¶
Update EOPF assets by extracting metadata and creating STAC items.
This Prefect task processes output products from a DPR (Data Processing Request) workflow, extracts EOPF (Earth Observation Processing Framework) metadata from the Zarr (v2 or v3) root group attributes, and generates STAC (SpatioTemporal Asset Catalog) items for each discovered product.
Workflow
- Finds the Zarr product stores in the output product paths with the zarr library
- Reads and validates EOPF discovery metadata from each Zarr root group attributes
- Extracts product type information
- Creates corresponding STAC items for catalog registration
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
Environment configuration object containing runtime settings. |
required | |
input_products
|
list[FlowInputProduct]
|
Source product references (excluding auxiliary inputs). |
required |
payload
|
PayloadSchema
|
PayloadSchema object containing I/O configuration, including output_product paths to scan for Zarr products. |
required |
dpr_processor
|
str
|
str DPR processor name |
required |
Returns:
| Type | Description |
|---|---|
list[DprProcessedItemMetadata]
|
A list of DprProcessedItemMetadata objects, each containing: - stac_item (Item): STAC item created from EOPF metadata. - product_type (str): Product type extracted from the Zarr root attributes. - output_product_id (str): The ID of the original output product. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If any Zarr product metadata cannot be read or does not contain required EOPF discovery metadata (stac_discovery.properties). |
Notes
- Requires Zarr root attributes to follow EOPF metadata conventions
- Each Zarr root group must contain stac_discovery.properties.product:type
- Uses S3 storage backend (via s3_list and read_zarr_attributes functions)
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
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 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |