From c7bf137e5d24972267a9470b95d9d908d0e4d3bf Mon Sep 17 00:00:00 2001 From: sdimovv <36302090+sdimovv@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:21:56 +0000 Subject: [PATCH] Added __eq__ method to Checkpoint class Signed-off-by: sdimovv <36302090+sdimovv@users.noreply.github.com> --- docker/models/checkpoints.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docker/models/checkpoints.py b/docker/models/checkpoints.py index 5136bd4a..65f0a89f 100644 --- a/docker/models/checkpoints.py +++ b/docker/models/checkpoints.py @@ -33,7 +33,11 @@ class Checkpoint(Model): checkpoint=self.id, checkpoint_dir=self.collection.checkpoint_dir, ) - + + def __eq__(self, other): + if isinstance(other, Checkpoint): + return self.id == other.id + return self.id == other class CheckpointCollection(Collection): """(Experimental).""" @@ -94,7 +98,7 @@ class CheckpointCollection(Collection): checkpoints = self.list() for checkpoint in checkpoints: - if checkpoint.id == id: + if checkpoint == id: return checkpoint raise CheckpointNotFound(