Skip to content

Commit 99011c6

Browse files
authored
Show warning on missing backend deps (#1911)
1 parent f457ca4 commit 99011c6

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/dstack/_internal/server/services/backends/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import heapq
3-
from typing import Callable, Coroutine, Dict, List, Optional, Tuple, Type, Union
3+
from typing import Callable, Coroutine, Dict, Iterable, List, Optional, Tuple, Type, Union
44
from uuid import UUID
55

66
from sqlalchemy import delete, update
@@ -229,7 +229,7 @@ async def get_config_info(
229229
async def delete_backends(
230230
session: AsyncSession,
231231
project: ProjectModel,
232-
backends_types: List[BackendType],
232+
backends_types: Iterable[BackendType],
233233
):
234234
if BackendType.DSTACK in backends_types:
235235
raise ServerClientError("Cannot delete dstack backend")

src/dstack/_internal/server/services/config.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing_extensions import Annotated
88

99
from dstack._internal.core.errors import (
10+
BackendNotAvailable,
1011
ResourceNotExistsError,
1112
ServerClientError,
1213
)
@@ -527,18 +528,23 @@ async def _apply_project_config(
527528
project = await projects_services.get_project_model_by_name_or_error(
528529
session=session, project_name=project_config.name
529530
)
530-
backends_to_delete = backends_services.list_available_backend_types()
531+
backends_to_delete = set(backends_services.list_available_backend_types())
531532
for backend_config in project_config.backends or []:
532533
config_info = config_to_internal_config(backend_config)
533534
backend_type = BackendType(config_info.type)
535+
backends_to_delete.difference_update([backend_type])
534536
try:
535-
backends_to_delete.remove(backend_type)
536-
except ValueError:
537+
current_config_info = await backends_services.get_config_info(
538+
project=project,
539+
backend_type=backend_type,
540+
)
541+
except BackendNotAvailable:
542+
logger.warning(
543+
"Backend %s not available and won't be configured."
544+
" Check that backend dependencies are installed.",
545+
backend_type.value,
546+
)
537547
continue
538-
current_config_info = await backends_services.get_config_info(
539-
project=project,
540-
backend_type=backend_type,
541-
)
542548
if config_info == current_config_info:
543549
continue
544550
backend_exists = any(backend_type == b.type for b in project.backends)

0 commit comments

Comments
 (0)