Skip to content

Commit

Permalink
Bug: cluster ids (Qiskit#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
IceKhan13 authored Jun 22, 2023
1 parent 2531c9d commit c7548c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gateway/api/schedule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Scheduling related functions."""
import random
import uuid
from typing import List

from django.conf import settings
Expand Down Expand Up @@ -47,13 +48,14 @@ def execute_job(job: Job) -> Job:
"""
authors_resource = ComputeResource.objects.filter(owner=job.author).first()

cluster_name = f"cluster-{job.author.username}-{str(uuid.uuid4())[:8]}"
if authors_resource:
job.compute_resource = authors_resource
job = submit_ray_job(job)
job.status = Job.PENDING
job.save()
else:
compute_resource = create_ray_cluster(job.author)
compute_resource = create_ray_cluster(job.author, cluster_name=cluster_name)
if compute_resource:
# if compute resource was created in time with no problems
job.compute_resource = compute_resource
Expand All @@ -64,7 +66,7 @@ def execute_job(job: Job) -> Job:
else:
# if something went wrong
# try to kill resource if it was allocated
kill_ray_cluster(job.author.username)
kill_ray_cluster(cluster_name)
job.status = Job.FAILED
job.logs = "Something went wrong during compute resource allocation."
job.save()
Expand Down

0 comments on commit c7548c6

Please sign in to comment.