Skip to content

Commit

Permalink
skip 2xx check on Oras-py Registry.push response
Browse files Browse the repository at this point in the history
Signed-off-by: Isabella do Amaral <[email protected]>
  • Loading branch information
isinyaaa committed Oct 28, 2024
1 parent bb445ec commit aa2331a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion omlmd/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 6 additions & 7 deletions omlmd/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/test_e2e_model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit aa2331a

Please sign in to comment.