rs_dpr_service/dask/call_dask.md
This module contains the code that is related to dask and/or sent to the dask workers. Avoid import unnecessary dependencies here.
ClusterInfo
dataclass
Information to connect to a DPR Dask cluster.
Attributes:
| Name | Type | Description |
|---|---|---|
jupyter_token |
str
|
JupyterHub API token. Only used in cluster mode, not local mode. |
cluster_label |
str
|
Dask cluster label e.g. "dask-l0" |
cluster_instance |
str | None
|
Dask cluster instance ID (something like "dask-gateway.17e196069443463495547eb97f532834"). |
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
ProcessorCaller
Run the DPR processor.
NOTE: All methods except init are run from the dask pod.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
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 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 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 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 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | |
__init__(caller_env, span_context, cluster_address, cluster_info, data, use_mockup)
Constructor.
Attributes:
| Name | Type | Description |
|---|---|---|
caller_env |
env variables coming from the caller |
|
span_context |
OpenTelemetry caller span context |
|
cluster_address |
Dask Gateway address |
|
cluster_info |
Information to connect to a DPR Dask cluster. |
|
data |
data to send to the processor |
|
use_mockup |
use the mockup or real processor |
|
s3 |
Bucket access to read/write configuration and report files |
|
local_report_dir |
Report directory on the local disk |
|
s3_report_dir |
Report directory on the S3 bucket |
|
experimental_config |
Experimental configuration, used only for testing |
|
payload_contents |
Payload file contents |
|
command |
Command used to trigger eopf-cpm |
|
log_path |
Path of the logging file on local disk |
|
working_dir |
Working directory on local disk |
|
to_be_uploaded |
Output products to be uploaded to the s3 bucket at the end of the processor |
|
exec_times |
Execution times with their description |
|
mockup_return_value |
Mockup return value |
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
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 | |
copy_caller_env()
Copy environment variables from the calling service environment to the dask client. This function is run from inside the dask pod.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
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 | |
customize_payload_file(payload_dir, payload_file)
Customize the payload file values
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
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 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |
finalize()
Code to run at the end of the processor.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | |
get_tasktable(module_name, class_name)
Return the DPR tasktable. This function is run from inside the dask pod.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
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 | |
handle_experimental_config(payload_contents)
Handle the experimental configuration
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
handle_local_product(io_key, original_product)
Handle local products for the experimental configuration
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.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 | |
hide_secrets(log)
The logs print secrets in clear e.g 'key': '
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
288 289 290 291 292 293 294 295 296 297 298 299 | |
init()
Init from the dask pod.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
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 | |
run_processor()
Run processor from the dask pod.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
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 | |
set_aws_env()
Init the AWS environment variables from the bucket credentials.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
trigger()
Trigger eopf-cpm execution
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
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 672 673 674 675 676 677 678 679 | |
write_dask_context(payload_contents)
Write the Dask context configuration in the payload file. This Dask context is used by EOPF to connect to the Dask cluster.
NOTE: rs-dpr-service connects to the Dask cluster, then submits an EOPF triggering to this cluster. Then EOPF reads the Dask context from the payload file to submit the DPR processor run to this cluster.
We need to make sure that rs-dpr-service and EOPF use the same cluster.
So it's safer that rs-dpr-service writes the Dask context in the payload file with the same configuration that is used to submit the EOPF triggering.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
convert_safe_to_zarr(cfg)
Convert from legacy product (safe format) into Zarr format using EOPF in a subprocess.
This runs the rs_dpr_service.safe_to_zarr module as a subprocess, passing config as JSON string.
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
get_ip_address()
Return IP address, see: https://stackoverflow.com/a/166520
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
54 55 56 | |
upload_this_module(dask_client)
Upload this current module from the caller environment to the dask client.
WARNING: These modules should not import other modules that are not installed in the dask environment or you'll have import errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
clients
|
list of dask clients to which upload the modules. |
required |
Source code in docs/rs-dpr-service/rs_dpr_service/dask/call_dask.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |