Skip to content

Commit bf9b9b1

Browse files
author
Sergey Mezentsev
committed
To filter instances, use the spot field from the job_spec. Fixes #968
1 parent b9569bf commit bf9b9b1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/dstack/_internal/server/background/tasks/process_submitted_jobs.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from dstack._internal.core.models.profiles import (
1414
DEFAULT_RUN_TERMINATION_IDLE_TIME,
1515
CreationPolicy,
16-
SpotPolicy,
1716
TerminationPolicy,
1817
)
1918
from dstack._internal.core.models.runs import (
@@ -25,7 +24,6 @@
2524
Requirements,
2625
Run,
2726
RunSpec,
28-
get_policy_map,
2927
)
3028
from dstack._internal.server.db import get_session_ctx
3129
from dstack._internal.server.models import InstanceModel, JobModel, ProjectModel, RunModel
@@ -100,13 +98,17 @@ async def _process_submitted_job(session: AsyncSession, job_model: JobModel):
10098
project=project_model,
10199
pool_name=profile.pool_name,
102100
)
101+
102+
run = run_model_to_run(run_model)
103+
job = run.jobs[job_model.job_num]
104+
103105
async with PROCESSING_POOL_LOCK:
104106
pool_instances = get_pool_instances(pool)
105107

106108
requirements = Requirements(
107109
resources=run_spec.configuration.resources,
108110
max_price=profile.max_price,
109-
spot=get_policy_map(profile.spot_policy, default=SpotPolicy.ONDEMAND),
111+
spot=job.job_spec.requirements.spot,
110112
)
111113
relevant_instances = filter_pool_instances(
112114
pool_instances=pool_instances,
@@ -127,9 +129,6 @@ async def _process_submitted_job(session: AsyncSession, job_model: JobModel):
127129
await session.commit()
128130
return
129131

130-
run = run_model_to_run(run_model)
131-
job = run.jobs[job_model.job_num]
132-
133132
if profile.creation_policy == CreationPolicy.REUSE:
134133
logger.debug(*job_log("reuse instance failed", job_model))
135134
if job.is_retry_active():

0 commit comments

Comments
 (0)