-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function to create executors by name and keyword arguments
- Loading branch information
Showing
3 changed files
with
67 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from typing import Optional | ||
|
||
from cubed.runtime.types import Executor | ||
|
||
|
||
def create_executor(name: str, executor_options: Optional[dict] = None) -> Executor: | ||
"""Create an executor from an executor name.""" | ||
executor_options = executor_options or {} | ||
if name == "beam": | ||
from cubed.runtime.executors.beam import BeamDagExecutor | ||
|
||
return BeamDagExecutor(**executor_options) | ||
elif name == "coiled": | ||
from cubed.runtime.executors.coiled import CoiledFunctionsDagExecutor | ||
|
||
return CoiledFunctionsDagExecutor(**executor_options) | ||
elif name == "dask": | ||
from cubed.runtime.executors.dask_distributed_async import ( | ||
AsyncDaskDistributedExecutor, | ||
) | ||
|
||
return AsyncDaskDistributedExecutor(**executor_options) | ||
elif name == "lithops": | ||
from cubed.runtime.executors.lithops import LithopsDagExecutor | ||
|
||
return LithopsDagExecutor(**executor_options) | ||
elif name == "modal": | ||
from cubed.runtime.executors.modal_async import AsyncModalDagExecutor | ||
|
||
return AsyncModalDagExecutor(**executor_options) | ||
elif name == "modal-sync": | ||
from cubed.runtime.executors.modal import ModalDagExecutor | ||
|
||
return ModalDagExecutor(**executor_options) | ||
elif name == "single-threaded": | ||
from cubed.runtime.executors.python import PythonDagExecutor | ||
|
||
return PythonDagExecutor(**executor_options) | ||
elif name == "threads": | ||
from cubed.runtime.executors.python_async import AsyncPythonDagExecutor | ||
|
||
return AsyncPythonDagExecutor(**executor_options) | ||
else: | ||
raise ValueError(f"Unrecognized executor name: {name}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters