Skip to content

Commit

Permalink
To filter instances, use the spot field from the job_spec. Fixes #968
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Mezentsev committed Mar 5, 2024
1 parent b9569bf commit bf9b9b1
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from dstack._internal.core.models.profiles import (
DEFAULT_RUN_TERMINATION_IDLE_TIME,
CreationPolicy,
SpotPolicy,
TerminationPolicy,
)
from dstack._internal.core.models.runs import (
Expand All @@ -25,7 +24,6 @@
Requirements,
Run,
RunSpec,
get_policy_map,
)
from dstack._internal.server.db import get_session_ctx
from dstack._internal.server.models import InstanceModel, JobModel, ProjectModel, RunModel
Expand Down Expand Up @@ -100,13 +98,17 @@ async def _process_submitted_job(session: AsyncSession, job_model: JobModel):
project=project_model,
pool_name=profile.pool_name,
)

run = run_model_to_run(run_model)
job = run.jobs[job_model.job_num]

async with PROCESSING_POOL_LOCK:
pool_instances = get_pool_instances(pool)

requirements = Requirements(
resources=run_spec.configuration.resources,
max_price=profile.max_price,
spot=get_policy_map(profile.spot_policy, default=SpotPolicy.ONDEMAND),
spot=job.job_spec.requirements.spot,
)
relevant_instances = filter_pool_instances(
pool_instances=pool_instances,
Expand All @@ -127,9 +129,6 @@ async def _process_submitted_job(session: AsyncSession, job_model: JobModel):
await session.commit()
return

run = run_model_to_run(run_model)
job = run.jobs[job_model.job_num]

if profile.creation_policy == CreationPolicy.REUSE:
logger.debug(*job_log("reuse instance failed", job_model))
if job.is_retry_active():
Expand Down

0 comments on commit bf9b9b1

Please sign in to comment.