Run a diagnostic synchronously, in-process.
This is mainly useful for debugging and testing.
climate_ref.executor.LocalExecutor is a more general purpose executor.
Source code in packages/climate-ref/src/climate_ref/executor/synchronous.py
| class SynchronousExecutor:
"""
Run a diagnostic synchronously, in-process.
This is mainly useful for debugging and testing.
[climate_ref.executor.LocalExecutor][] is a more general purpose executor.
"""
name = "synchronous"
def __init__(
self, *, database: Database | None = None, config: Config | None = None, **kwargs: Any
) -> None:
if config is None:
config = Config.default()
if database is None:
database = Database.from_config(config, run_migrations=False)
self.database = database
self.config = config
def run(
self,
definition: ExecutionDefinition,
execution: Execution | None = None,
) -> None:
"""
Run a diagnostic in process
Parameters
----------
definition
A description of the information needed for this execution of the diagnostic
execution
A database model representing the execution of the diagnostic.
If provided, the result will be updated in the database when completed.
"""
result = execute_locally(definition, log_level=self.config.log_level)
process_result(self.config, self.database, result, execution)
def join(self, timeout: float) -> None:
"""
Wait for all diagnostics to finish
This returns immediately because the executor runs diagnostics synchronously.
Parameters
----------
timeout
Timeout in seconds (Not used)
"""
pass
|
join(timeout)
Wait for all diagnostics to finish
This returns immediately because the executor runs diagnostics synchronously.
Parameters:
| Name |
Type |
Description |
Default |
timeout
|
float
|
Timeout in seconds (Not used)
|
required
|
Source code in packages/climate-ref/src/climate_ref/executor/synchronous.py
| def join(self, timeout: float) -> None:
"""
Wait for all diagnostics to finish
This returns immediately because the executor runs diagnostics synchronously.
Parameters
----------
timeout
Timeout in seconds (Not used)
"""
pass
|
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/synchronous.py
| def run(
self,
definition: ExecutionDefinition,
execution: Execution | None = None,
) -> None:
"""
Run a diagnostic in process
Parameters
----------
definition
A description of the information needed for this execution of the diagnostic
execution
A database model representing the execution of the diagnostic.
If provided, the result will be updated in the database when completed.
"""
result = execute_locally(definition, log_level=self.config.log_level)
process_result(self.config, self.database, result, execution)
|