Skip to content

Commit b54fd31

Browse files
committed
Move run job lookup into analysis
1 parent 3704dd2 commit b54fd31

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

  • src/dstack/_internal/server/background/scheduled_tasks

src/dstack/_internal/server/background/scheduled_tasks/runs.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,10 @@ async def _process_active_run(session: AsyncSession, run_model: RunModel):
348348
run_spec = run.run_spec
349349
retry_single_job = _can_retry_single_job(run_spec)
350350
_maybe_set_run_fleet_id_from_jobs(run_model)
351-
run_jobs_by_position = _get_run_jobs_by_position(run)
352351
analysis = await _analyze_active_run(
353352
session=session,
354353
run_model=run_model,
355354
run=run,
356-
run_jobs_by_position=run_jobs_by_position,
357355
retry_single_job=retry_single_job,
358356
)
359357
transition = _get_active_run_transition(run, analysis)
@@ -368,18 +366,16 @@ async def _process_active_run(session: AsyncSession, run_model: RunModel):
368366
)
369367

370368

371-
def _get_run_jobs_by_position(run: Run) -> Dict[Tuple[int, int], Job]:
372-
return {(job.job_spec.replica_num, job.job_spec.job_num): job for job in run.jobs}
373-
374-
375369
async def _analyze_active_run(
376370
session: AsyncSession,
377371
run_model: RunModel,
378372
run: Run,
379-
run_jobs_by_position: Dict[Tuple[int, int], Job],
380373
retry_single_job: bool,
381374
) -> _RunAnalysis:
382375
run_analysis = _RunAnalysis()
376+
run_jobs_by_position = {
377+
(job.job_spec.replica_num, job.job_spec.job_num): job for job in run.jobs
378+
}
383379
for replica_num, job_models in group_jobs_by_replica_latest(run_model.jobs):
384380
replica_analysis = await _analyze_active_run_replica(
385381
session=session,

0 commit comments

Comments
 (0)