Skip to content

Commit

Permalink
fix: handle not found error for image or container
Browse files Browse the repository at this point in the history
  • Loading branch information
newgene committed May 21, 2023
1 parent 0c387c8 commit 042af67
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions biothings/hub/dataload/dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

try:
import docker
from docker.errors import NotFound, NullResource
from docker.errors import ImageNotFound, NotFound, NullResource

docker_avail = True
except ImportError:
Expand Down Expand Up @@ -1987,11 +1987,17 @@ def prepare_dumper_params(self):
raise DumperException("Either DOCKER_IMAGE or CONTAINER_NAME must be defined in the data plugin manifest")
# now read the metadata from the Docker image or container
if self.DOCKER_IMAGE:
image = self.client.images.get(self.DOCKER_IMAGE)
self.image_metadata = image.labels
try:
image = self.client.images.get(self.DOCKER_IMAGE)
self.image_metadata = image.labels
except ImageNotFound:
pass
elif self.CONTAINER_NAME:
container = self.client.containers.get(self.CONTAINER_NAME)
self.image_metadata = container.labels
try:
container = self.client.containers.get(self.CONTAINER_NAME)
self.image_metadata = container.labels
except (NotFound, NullResource):
pass
else:
self.image_metadata = {}

Expand Down

0 comments on commit 042af67

Please sign in to comment.