Skip to content

Commit 01a69d5

Browse files
committed
Show imported instances in dstack offer
Show instances from imported fleets in `dstack offer`. Previously, they were only shown in `dstack fleet`.
1 parent 8657913 commit 01a69d5

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,14 @@ async def get_pool_instances(
513513
res = await session.execute(
514514
select(InstanceModel)
515515
.where(
516-
InstanceModel.project_id == project.id,
516+
or_(
517+
InstanceModel.project_id == project.id,
518+
exists().where(
519+
ImportModel.project_id == project.id,
520+
ImportModel.export_id == ExportedFleetModel.export_id,
521+
ExportedFleetModel.fleet_id == InstanceModel.fleet_id,
522+
),
523+
),
517524
InstanceModel.deleted == False,
518525
)
519526
.options(joinedload(InstanceModel.fleet))

src/tests/_internal/server/routers/test_runs.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,11 +1388,22 @@ async def test_returns_run_plan_instance_volumes(
13881388

13891389
@pytest.mark.asyncio
13901390
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
1391+
@pytest.mark.parametrize(
1392+
"configuration",
1393+
[
1394+
pytest.param({"type": "dev-environment", "ide": "vscode"}, id="regular-configuration"),
1395+
pytest.param(
1396+
{"type": "task", "commands": [":"], "image": "scratch"},
1397+
id="special-configuration-used-by-dstack-offer-cli-command",
1398+
),
1399+
],
1400+
)
13911401
async def test_returns_run_plan_with_offer_from_imported_fleet(
13921402
self,
13931403
test_db,
13941404
session: AsyncSession,
13951405
client: AsyncClient,
1406+
configuration: dict,
13961407
) -> None:
13971408
importer_user = await create_user(session, global_role=GlobalRole.USER)
13981409
exporter_project = await create_project(session, name="exporter-project")
@@ -1424,7 +1435,7 @@ async def test_returns_run_plan_with_offer_from_imported_fleet(
14241435
exported_fleets=[fleet],
14251436
)
14261437

1427-
run_spec = {"configuration": {"type": "dev-environment", "ide": "vscode"}}
1438+
run_spec = {"configuration": configuration}
14281439
body = {"run_spec": run_spec}
14291440
response = await client.post(
14301441
"/api/project/importer-project/runs/get_plan",

0 commit comments

Comments
 (0)