Skip to content

Commit f55094a

Browse files
authored
Show imported instances in dstack offer (#3673)
Show instances from imported fleets in `dstack offer`. Previously, they were only shown in `dstack fleet`.
1 parent fc914c3 commit f55094a

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
@@ -504,7 +504,14 @@ async def get_pool_instances(
504504
res = await session.execute(
505505
select(InstanceModel)
506506
.where(
507-
InstanceModel.project_id == project.id,
507+
or_(
508+
InstanceModel.project_id == project.id,
509+
exists().where(
510+
ImportModel.project_id == project.id,
511+
ImportModel.export_id == ExportedFleetModel.export_id,
512+
ExportedFleetModel.fleet_id == InstanceModel.fleet_id,
513+
),
514+
),
508515
InstanceModel.deleted == False,
509516
)
510517
.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)