Skip to content

Commit

Permalink
Fix test_image_spec (flyteorg#2477)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: bugra.gedik <[email protected]>
  • Loading branch information
pingsutw authored and bugra.gedik committed Jul 3, 2024
1 parent 0caf47a commit e0498c1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions flytekit/image_spec/image_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def is_container(self) -> bool:
return os.environ.get(_F_IMG_ID) == self.image_name()
return True

@lru_cache
def exist(self) -> bool:
"""
Check if the image exists in the registry.
Expand All @@ -127,10 +126,14 @@ def exist(self) -> bool:
return False
except Exception as e:
tag = calculate_hash_from_image_spec(self)
# if docker engine is not running locally
container_registry = DOCKER_HUB
if self.registry and "/" in self.registry:
# if docker engine is not running locally, use requests to check if the image exists.
if "localhost:" in self.registry:
container_registry = self.registry
elif self.registry and "/" in self.registry:
container_registry = self.registry.split("/")[0]
else:
# Assume the image is in docker hub if users don't specify a registry, such as ghcr.io, docker.io.
container_registry = DOCKER_HUB
if container_registry == DOCKER_HUB:
url = f"https://hub.docker.com/v2/repositories/{self.registry}/{self.name}/tags/{tag}"
response = requests.get(url)
Expand Down

0 comments on commit e0498c1

Please sign in to comment.