From a8ee5e20aca44a48d58086c44c911c0a33cbf888 Mon Sep 17 00:00:00 2001 From: Isabella do Amaral Date: Mon, 28 Oct 2024 15:17:43 -0300 Subject: [PATCH] skip 2xx check on Oras-py Registry.push response Signed-off-by: Isabella do Amaral --- omlmd/helpers.py | 4 +++- omlmd/listener.py | 13 ++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/omlmd/helpers.py b/omlmd/helpers.py index 41f67c2..4a254f3 100644 --- a/omlmd/helpers.py +++ b/omlmd/helpers.py @@ -97,7 +97,9 @@ def push( manifest_config=manifest_cfg, do_chunked=True, ) - self.notify_listeners(PushEvent(result, target, model_metadata)) + self.notify_listeners( + PushEvent.from_response(result, target, model_metadata) + ) return result finally: if owns_meta_files: diff --git a/omlmd/listener.py b/omlmd/listener.py index 7e15b62..7c57bfe 100644 --- a/omlmd/listener.py +++ b/omlmd/listener.py @@ -28,13 +28,12 @@ class Event(ABC): @dataclass class PushEvent(Event): - response: requests.Response + digest: str target: str metadata: ModelMetadata - @property - def ok(self) -> bool: - return self.response.status_code == 200 - - def get_digest(self) -> str: - return self.response.headers["Docker-Content-Digest"] if self.ok else "" + @classmethod + def from_response( + cls, response: requests.Response, target: str, metadata: ModelMetadata + ) -> t.Self: + return cls(response.headers["Docker-Content-Digest"], target, metadata)