climate_ref_core.executor
#
Executor interface for running diagnostics
Executor
#
Bases: Protocol
An executor is responsible for running a diagnostic asynchronously
The diagnostic may be run locally in the same process or in a separate process or container.
Notes
This is an extremely basic interface and will be expanded in the future, as we figure out our requirements.
Source code in packages/climate-ref-core/src/climate_ref_core/executor.py
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 | |
collects_results_on_join
instance-attribute
#
Whether execution results are only collected and persisted during join.
When True (e.g. the local process pool and HPC executors), skipping join
(via --no-wait) leaves completed outputs in the scratch directory
without copying them to the results directory or ingesting them.
When False (e.g. the synchronous and Celery executors),
results are persisted elsewhere (inline in run or by a worker callback),
so join only waits for completion.
join(timeout)
#
Wait for all executions to finish
If the timeout is reached, the method will return and raise an exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time to wait for all executions to finish in seconds |
required |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If the timeout is reached |
Source code in packages/climate-ref-core/src/climate_ref_core/executor.py
run(definition, execution=None)
#
Execute a diagnostic with a given definition
No executions are returned from this method, as the execution may be performed asynchronously so executions may not be immediately available.
Note
In future, we may return a Future object that can be used to retrieve the result,
but that requires some additional work to implement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
definition
|
ExecutionDefinition
|
Definition of the information needed to execute a diagnostic This definition describes which datasets are required to run the diagnostic and where the output should be stored. |
required |
execution
|
Any
|
The execution object to update with the results of the execution. This is a database object that contains the executions of the execution. If provided, it will be updated with the executions of the execution. This may happen asynchronously, so the executions may not be immediately available. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
Results from running the diagnostic |
Source code in packages/climate-ref-core/src/climate_ref_core/executor.py
execute_locally(definition, log_level, raise_error=False)
#
Run a diagnostic execution
This is the chunk of work that should be executed by an executor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
definition
|
ExecutionDefinition
|
A description of the information needed for this execution of the diagnostic |
required |
log_level
|
str
|
The log level to use for the execution |
required |
Source code in packages/climate-ref-core/src/climate_ref_core/executor.py
import_executor_cls(fqn)
#
Import an executor using a fully qualified module path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fqn
|
str
|
Full package and attribute name of the executor to import For example: |
required |
Raises:
| Type | Description |
|---|---|
InvalidExecutorException
|
If the executor cannot be imported If the executor isn't a valid |
Returns:
| Type | Description |
|---|---|
type[Executor]
|
Executor instance |