Skip to content

Commit

Permalink
Merge branch 'staging' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf committed May 13, 2024
2 parents 0e45bb1 + 3cc4b7e commit a7b1b52
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/api/specs/WorkflowsAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2123,8 +2123,6 @@ components:
pipeline_run_uuid:
type: string
format: uuid
acquired:
type: boolean
created_at:
type: string
acquired_at:
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
14 changes: 6 additions & 8 deletions src/api/src/backend/serializers/PipelineLockModelSerializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion src/api/src/backend/views/PipelineLocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a7b1b52

Please sign in to comment.