|
9 | 9 | ) |
10 | 10 | from dstack._internal.core.backends.base.configurator import Configurator |
11 | 11 | from dstack._internal.core.backends.configurators import list_available_configurator_classes |
| 12 | +from dstack._internal.core.backends.local.compute import LocalCompute |
12 | 13 | from dstack._internal.core.models.backends.base import BackendType |
| 14 | +from dstack._internal.server.settings import LOCAL_BACKEND_ENABLED |
13 | 15 |
|
14 | 16 |
|
15 | 17 | def _get_backends_with_compute_feature( |
16 | 18 | configurator_classes: list[type[Configurator]], |
17 | 19 | compute_feature_class: type, |
18 | 20 | ) -> list[BackendType]: |
| 21 | + backend_types_and_computes = [ |
| 22 | + (configurator_class.TYPE, configurator_class.BACKEND_CLASS.COMPUTE_CLASS) |
| 23 | + for configurator_class in configurator_classes |
| 24 | + ] |
| 25 | + if LOCAL_BACKEND_ENABLED: |
| 26 | + backend_types_and_computes.append((BackendType.LOCAL, LocalCompute)) |
19 | 27 | backend_types = [] |
20 | | - for configurator_class in configurator_classes: |
21 | | - compute_class = configurator_class.BACKEND_CLASS.COMPUTE_CLASS |
| 28 | + for backend_type, compute_class in backend_types_and_computes: |
22 | 29 | if issubclass(compute_class, compute_feature_class): |
23 | | - backend_types.append(configurator_class.TYPE) |
| 30 | + backend_types.append(backend_type) |
24 | 31 | return backend_types |
25 | 32 |
|
26 | 33 |
|
27 | 34 | _configurator_classes = list_available_configurator_classes() |
28 | 35 |
|
29 | 36 |
|
30 | 37 | # The following backend lists do not include unavailable backends (i.e. backends missing deps). |
31 | | -# TODO: Add LocalBackend to lists if it's enabled |
32 | 38 | BACKENDS_WITH_CREATE_INSTANCE_SUPPORT = _get_backends_with_compute_feature( |
33 | 39 | configurator_classes=_configurator_classes, |
34 | 40 | compute_feature_class=ComputeWithCreateInstanceSupport, |
|
0 commit comments