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..8122fde 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 + ) -> "PushEvent": + return cls(response.headers["Docker-Content-Digest"], target, metadata) diff --git a/tests/test_e2e_model_registry.py b/tests/test_e2e_model_registry.py index 39adc26..972b0ac 100644 --- a/tests/test_e2e_model_registry.py +++ b/tests/test_e2e_model_registry.py @@ -43,7 +43,7 @@ class ListenerForModelRegistry(Listener): def update(self, source: Helper, event: Event) -> None: if isinstance(event, PushEvent): - self.sha = event.get_digest() + self.sha = event.digest self.rm = from_oci_to_kfmr(model_registry, event, self.sha) listener = ListenerForModelRegistry()