Skip to content

Commit 2cacada

Browse files
authored
Support fleet configurations for the local backend (#2856)
Add the local backend to `BACKENDS_WITH_*_SUPPORT` so that it can be used in fleet configurations.
1 parent 578e04a commit 2cacada

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/dstack/_internal/core/backends/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,32 @@
99
)
1010
from dstack._internal.core.backends.base.configurator import Configurator
1111
from dstack._internal.core.backends.configurators import list_available_configurator_classes
12+
from dstack._internal.core.backends.local.compute import LocalCompute
1213
from dstack._internal.core.models.backends.base import BackendType
14+
from dstack._internal.server.settings import LOCAL_BACKEND_ENABLED
1315

1416

1517
def _get_backends_with_compute_feature(
1618
configurator_classes: list[type[Configurator]],
1719
compute_feature_class: type,
1820
) -> 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))
1927
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:
2229
if issubclass(compute_class, compute_feature_class):
23-
backend_types.append(configurator_class.TYPE)
30+
backend_types.append(backend_type)
2431
return backend_types
2532

2633

2734
_configurator_classes = list_available_configurator_classes()
2835

2936

3037
# The following backend lists do not include unavailable backends (i.e. backends missing deps).
31-
# TODO: Add LocalBackend to lists if it's enabled
3238
BACKENDS_WITH_CREATE_INSTANCE_SUPPORT = _get_backends_with_compute_feature(
3339
configurator_classes=_configurator_classes,
3440
compute_feature_class=ComputeWithCreateInstanceSupport,

0 commit comments

Comments
 (0)