climate_ref.executor.result_handling
#
Execute diagnostics in different environments
We support running diagnostics in different environments, such as locally,
in a separate process, or in a container.
These environments are represented by climate_ref.executor.Executor classes.
The simplest executor is the LocalExecutor, which runs the diagnostic in the same process.
This is useful for local testing and debugging.
ExecutionFuture
#
A container linking a submitted future to its execution metadata.
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
handle_execution_result(config, database, execution, result, *, update_dirty=True)
#
Handle the result of a diagnostic execution
This will update the diagnostic execution result with the output of the diagnostic execution. The output will be copied from the scratch directory to the executions directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
The configuration to use |
required |
database
|
Database
|
The active database session to use |
required |
execution
|
Execution
|
The diagnostic execution result DB object to update |
required |
result
|
ExecutionResult
|
The result of the diagnostic execution, either successful or failed |
required |
update_dirty
|
bool
|
Whether to update the execution group's dirty flag. Set to False for reingest which should not alter pending-work state. |
True
|
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
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 | |
ingest_execution_result(database, execution, result, cv, *, output_base_path)
#
Ingest a successful execution result into the database.
Registers output entries and ingests scalar and series metric values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
Database
|
The active database session to use |
required |
execution
|
Execution
|
The execution record to associate results with |
required |
result
|
ExecutionResult
|
The successful execution result |
required |
cv
|
CV
|
The controlled vocabulary to validate metrics against |
required |
output_base_path
|
Path
|
Primary base directory for resolving output filenames |
required |
Notes
Callers are responsible for:
- File copying (scratch -> results)
- Transaction boundaries
- Marking the execution as successful (
execution.mark_successful()) - Setting the dirty flag on the execution group
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
ingest_scalar_values(database, result, execution, cv)
#
Load, validate, and bulk-insert scalar metric values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
Database
|
The active database session to use |
required |
result
|
ExecutionResult
|
The execution result containing the metric bundle filename |
required |
execution
|
Execution
|
The execution record to associate values with |
required |
cv
|
CV
|
The controlled vocabulary to validate against |
required |
Notes
Callers are responsible for transaction boundaries; this function does not open a nested transaction or catch exceptions.
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
ingest_series_values(database, result, execution, cv)
#
Load, validate, and bulk-insert series metric values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
Database
|
The active database session to use |
required |
result
|
ExecutionResult
|
The execution result containing the series filename |
required |
execution
|
Execution
|
The execution record to associate values with |
required |
cv
|
CV
|
The controlled vocabulary to validate against |
required |
Notes
Callers are responsible for transaction boundaries; this function does not open a nested transaction or catch exceptions.
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
mark_execution_failed(database, config, definition, execution_id, *, retryable)
#
Persist a failed result for an outstanding execution.
Used when an executor abandons a future (per-task timeout, overall timeout,
worker crash) so the corresponding Execution row never stays stuck in
successful=None state.
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
process_result(config, database, result, execution)
#
Process the result of a diagnostic execution, persisting outcome to the DB.
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
register_execution_outputs(database, execution, outputs, output_type, *, base_path)
#
Register output entries in the database.
Each entry in outputs is resolved relative to base_path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
Database
|
The active database session to use |
required |
execution
|
Execution
|
The execution record to associate outputs with |
required |
outputs
|
dict[str, OutputDict] | None
|
Mapping of short name to |
required |
output_type
|
ResultOutputType
|
The type of output being registered |
required |
base_path
|
Path
|
Base directory for resolving relative filenames |
required |
Notes
Callers are responsible for transaction boundaries.