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
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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
extract_products_and_zattrs(files, base_path, *, zarr_v3=True)
¶
Extract product names and their corresponding .zattrs file paths.
With zarr_v3=True, also discover zarr.json and prefer it per product.
Filters a list of file paths to find .zattrs files located under product directories within a base path, following one of these structures: base_path/.zattrs base_path/product_name/.zattrs base_path/products/product_name/.zattrs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[str]
|
List of file paths to search through. |
required |
base_path
|
str
|
The base directory path to strip from file paths. |
required |
Returns:
| Type | Description |
|---|---|
|
A list of tuples, where each tuple contains: - product_name (str): The name of the product directory. - file (str): The full path to the .zattrs file. |
|
|
If |
|
|
and nested group metadata is ignored. Otherwise, includes files that are |
|
|
directly under a product directory, with an optional |
|
|
container directory under the base path. |
Example
files = [ ... "/data/products/product_a/.zattrs", ... "/data/products/product_b/.zattrs", ... "/data/products/product_c/subdir/file.txt" ... ] extract_products_and_zattrs(files, "/data/products") [('product_a', '/data/products/product_a/.zattrs'), ('product_b', '/data/products/product_b/.zattrs')]
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
find_zarr_zip(zattrs_s3_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 |
|---|---|---|---|
zattrs_s3_location
|
str
|
S3 path of the product root |
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
read_zattrs_sync(path)
¶
Read a .zattrs file from S3 synchronously and return the parsed JSON, in memory.
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
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 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |
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 .zattrs files, and generates STAC (SpatioTemporal Asset Catalog) items for each discovered product.
Workflow
- Lists all .zattrs files in the output product paths
- Reads and validates EOPF discovery metadata from each .zattrs file
- 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 .zattrs files. |
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 .zattrs file. - output_product_id (str): The ID of the original output product. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If any .zattrs file cannot be read or does not contain required EOPF discovery metadata (stac_discovery.properties). |
Notes
- Requires .zattrs files to follow EOPF metadata conventions
- Each .zattrs file must contain stac_discovery.properties.product:type
- Uses S3 storage backend (via s3_list and read_zattrs_sync functions)
Source code in docs/rs-client-libraries/rs_workflows/dpr_flow.py
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 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |