Skip to content

Commit

Permalink
fix: Outdated image string join logic in ImageRow.image_ref (#3125) (
Browse files Browse the repository at this point in the history
…#3164)

Co-authored-by: Gyubong Lee <[email protected]>
  • Loading branch information
lablup-octodog and jopemachine authored Nov 28, 2024
1 parent 101f0c5 commit 01d8f32
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/3125.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix outdated image string join logic in `ImageRow.image_ref`.
2 changes: 1 addition & 1 deletion src/ai/backend/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def is_ip_address_format(str: str) -> bool:
return False


def join_non_empty(*args, sep):
def join_non_empty(*args: Optional[str], sep: str) -> str:
"""
Joins non-empty strings from the given arguments using the specified separator.
"""
Expand Down
4 changes: 3 additions & 1 deletion src/ai/backend/manager/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
ImageRegistry,
ResourceSlot,
)
from ai.backend.common.utils import join_non_empty
from ai.backend.logging import BraceStyleAdapter
from ai.backend.manager.models.container_registry import ContainerRegistryRow

Expand Down Expand Up @@ -242,7 +243,8 @@ def image_ref(self) -> ImageRef:
image_name = ""
_, tag = ImageRef.parse_image_tag(self.name.split(f"{self.registry}/", maxsplit=1)[1])
else:
image_and_tag = self.name.split(f"{self.registry}/{self.project}/", maxsplit=1)[1]
join = functools.partial(join_non_empty, sep="/")
image_and_tag = self.name.removeprefix(f"{join(self.registry, self.project)}/")
image_name, tag = ImageRef.parse_image_tag(image_and_tag)

return ImageRef(
Expand Down

0 comments on commit 01d8f32

Please sign in to comment.