|
14 | 14 | import warnings
|
15 | 15 | from datetime import datetime
|
16 | 16 | from types import TracebackType
|
17 |
| -from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type |
| 17 | +from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar |
18 | 18 |
|
19 | 19 | from torchx.runner.events import log_event
|
20 | 20 | from torchx.schedulers import get_scheduler_factories, SchedulerFactory
|
|
41 | 41 | )
|
42 | 42 |
|
43 | 43 | from torchx.util.types import none_throws
|
44 |
| -from torchx.workspace.api import WorkspaceMixin |
| 44 | +from torchx.workspace.api import PkgInfo, WorkspaceBuilder, WorkspaceMixin |
45 | 45 |
|
46 | 46 | from .config import get_config, get_configs
|
47 | 47 |
|
48 | 48 | logger: logging.Logger = logging.getLogger(__name__)
|
49 | 49 |
|
50 | 50 |
|
51 | 51 | NONE: str = "<NONE>"
|
| 52 | +S = TypeVar("S") |
| 53 | +T = TypeVar("T") |
52 | 54 |
|
53 | 55 |
|
54 | 56 | def get_configured_trackers() -> Dict[str, Optional[str]]:
|
@@ -147,6 +149,18 @@ def close(self) -> None:
|
147 | 149 | for scheduler in self._scheduler_instances.values():
|
148 | 150 | scheduler.close()
|
149 | 151 |
|
| 152 | + def build_standalone_workspace( |
| 153 | + self, |
| 154 | + workspace_builder: WorkspaceBuilder[S, T], |
| 155 | + sync: bool = True, |
| 156 | + ) -> PkgInfo[S]: |
| 157 | + """ |
| 158 | + Build a standalone workspace for the given role. |
| 159 | + This method is used to build a workspace for a role independent of the scheduler and |
| 160 | + also enables asynchronous workspace building using the Role overrides. |
| 161 | + """ |
| 162 | + return workspace_builder.build_workspace(sync) |
| 163 | + |
150 | 164 | def run_component(
|
151 | 165 | self,
|
152 | 166 | component: str,
|
|
0 commit comments