climate_ref.executor.local
#
ExecutionFuture
#
A container linking a submitted future to its execution metadata.
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
definition
instance-attribute
#
The execution definition associated with this future.
execution_id = None
class-attribute
instance-attribute
#
The ID of the execution associated with this future, or None if not yet assigned.
future
instance-attribute
#
The future representing the asynchronous execution of this task.
This future has a base-class of concurrent.futures.Future,
but the concrete class of the instance will depend on the executor.
queue_seconds
property
#
Time spent waiting between submission and the start of execution, in seconds.
None when the start of execution could not be established.
started_at = None
class-attribute
instance-attribute
#
Wall-clock time (time.time()) at which a worker was first observed running this future,
or None while it is still queued.
The per-task timeout is budgeted against this rather than submitted_at
so that time spent waiting in the pool queue is not counted as execution time.
submitted_at = 0.0
class-attribute
instance-attribute
#
Wall-clock time (time.time()) at which this future was submitted to the executor.
infer_started_at(result, observed_at)
#
Place started_at using the worker's own wall time, if a poll never observed the start.
A task submitted and finished between two polls is never seen running, which would leave the queue latency unrecorded for every short execution. The worker measured how long it ran, so subtracting that from the moment completion was observed puts the start within one poll interval of the truth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
ExecutionResult
|
The finished result, whose |
required |
observed_at
|
float
|
Wall-clock time ( |
required |
Source code in packages/climate-ref/src/climate_ref/executor/result_handling.py
LocalExecutor
#
Run a diagnostic locally using a process pool.
This performs the diagnostic executions in parallel using different processes.
The maximum number of processes is determined by the n parameter and default to the number of CPUs.
This executor is the default executor and is used when no other executor is specified.
Source code in packages/climate-ref/src/climate_ref/executor/local.py
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 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 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 | |
join(timeout)
#
Wait for all diagnostics to finish
This will block until all diagnostics have completed or the timeout is reached.
Each individual execution is also bounded by self.task_timeout,
measured from when a worker starts running it,
so that a hung diagnostic cannot block the pool indefinitely.
Tasks still waiting in the pool queue are never culled by this budget,
only the overall timeout applies to them.
Outstanding executions are always marked as failed-retryable before this method returns or raises,
so the next solve can pick them up rather than seeing them stuck with successful=None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Overall wall-clock timeout in seconds for the whole join.
A non-positive value ( |
required |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If a positive overall timeout is reached |
Source code in packages/climate-ref/src/climate_ref/executor/local.py
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 | |
run(definition, execution=None)
#
Run a diagnostic in process
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
definition
|
ExecutionDefinition
|
A description of the information needed for this execution of the diagnostic |
required |
execution
|
Execution | None
|
A database model representing the execution of the diagnostic. If provided, the result will be updated in the database when completed. |
None
|
Source code in packages/climate-ref/src/climate_ref/executor/local.py
process_result(config, database, result, execution, *, queue_seconds=None, detail=None)
#
Process the result of a diagnostic execution, persisting outcome to the DB.
queue_seconds is supplied by the submitting executor,
because only the parent knows when the task was submitted.
detail says why a failed execution failed and is written to its results log.