Skip to content

Commit

Permalink
Fix pipeline lock serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf committed May 13, 2024
1 parent 38914b5 commit 3cc4b7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/api/src/backend/serializers/PipelineLockModelSerializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@
class PipelineLockModelSerializer:
@staticmethod
def serialize(model):
print(model)
print(dir(model))
print(vars(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
2 changes: 2 additions & 0 deletions src/api/src/backend/views/PipelineLocks.py
Original file line number Diff line number Diff line change
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 3cc4b7e

Please sign in to comment.