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.
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.
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
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 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 | |
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
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 | |
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)
#
Process the result of a diagnostic execution, persisting outcome to the DB.