diff --git a/src/api/specs/WorkflowsAPI.yaml b/src/api/specs/WorkflowsAPI.yaml index 46097b7b..73dd7d22 100644 --- a/src/api/specs/WorkflowsAPI.yaml +++ b/src/api/specs/WorkflowsAPI.yaml @@ -2123,8 +2123,6 @@ components: pipeline_run_uuid: type: string format: uuid - acquired: - type: boolean created_at: type: string acquired_at: diff --git a/src/api/src/backend/serializers/PipelineLockAcquisitionResponseSerializer.py b/src/api/src/backend/serializers/PipelineLockAcquisitionResponseSerializer.py index 92e5b1f1..9fda6000 100644 --- a/src/api/src/backend/serializers/PipelineLockAcquisitionResponseSerializer.py +++ b/src/api/src/backend/serializers/PipelineLockAcquisitionResponseSerializer.py @@ -1,12 +1,11 @@ from backend.serializers import UUIDSerializer -from backend.conf.constants import DATETIME_FORMAT class PipelineLockAcquisitionResponseSerializer: @staticmethod def serialize(pipeline_lock, message): return { - "acquired": pipeline_lock.acquired, + "acquired": pipeline_lock.acquired_at != None, "message": message, "pipeline_lock_uuid": UUIDSerializer.serialize(pipeline_lock.uuid) } \ No newline at end of file diff --git a/src/api/src/backend/serializers/PipelineLockModelSerializer.py b/src/api/src/backend/serializers/PipelineLockModelSerializer.py index 3a6020c4..34c62229 100644 --- a/src/api/src/backend/serializers/PipelineLockModelSerializer.py +++ b/src/api/src/backend/serializers/PipelineLockModelSerializer.py @@ -7,17 +7,15 @@ class PipelineLockModelSerializer: @staticmethod def serialize(model): - lock = model_to_dict(model) - lock["uuid"] = UUIDSerializer.serialize(lock["uuid"]) - lock["created_at"] = lock["created_at"].strftime(DATETIME_FORMAT) + lock = {} + lock["uuid"] = UUIDSerializer.serialize(lock.uuid) + lock["created_at"] = lock.created_at.strftime(DATETIME_FORMAT) + lock["expires_in"] = lock.expires_in - if lock["acquired_at"] != None: - lock["acquired_at"] = lock["acquired_at"].strftime(DATETIME_FORMAT) + if lock.acquired_at != None: + lock["acquired_at"] = lock.acquired_at.strftime(DATETIME_FORMAT) lock["pipeline_id"] = model.pipeline.id - del lock["pipeline"] - lock["pipeline_run_uuid"] = UUIDSerializer.serialize(model.pipeline_run.uuid) - del lock["pipeline_run"] return lock \ No newline at end of file diff --git a/src/api/src/backend/views/PipelineLocks.py b/src/api/src/backend/views/PipelineLocks.py index 98c65d23..8a5285ac 100644 --- a/src/api/src/backend/views/PipelineLocks.py +++ b/src/api/src/backend/views/PipelineLocks.py @@ -104,7 +104,7 @@ def post(self, request, group_id, pipeline_id): # Check to see if the pipeline run associated with the current # pipeline lock attempt is the next in the queue. If so, update the - # pipeline lock's 'acquired' property to 'true' + # pipeline lock's 'acquired_at' property if pipeline_lock.pipeline_run.uuid == competing_runs[0]: acquired_at = timezone.now() pipeline_lock.object.update(acquired_at=acquired_at) @@ -186,6 +186,8 @@ def get(self, request, group_id, pipeline_id, pipeline_lock_uuid=None, *_, **__ id=pipeline_id ).prefetch_related( "pipelinelocks" + "pipeline__pipeline" + "pipelinelocks__pipeline_run" ).first() # Return if BadRequest if no pipeline found