Skip to content

Commit

Permalink
Merge pull request #352 from DigitalSlideArchive/duplicate-cli-images
Browse files Browse the repository at this point in the history
Remove duplicates from list of cli images to provision
  • Loading branch information
manthey authored Aug 19, 2024
2 parents a244d61 + a950fbc commit 5e59ecb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions devops/dsa/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def get_slicer_images(imageList, adminUser, alwaysPull=False):
job = Job().load(id=job['_id'], user=adminUser, includeLog=True)
if 'log' in job:
while logpos < len(job['log']):
logger.info(job['log'][logpos].rstrip())
if 'Pulling' not in job['log'][logpos] or '%' not in job['log'][logpos]:
logger.info(job['log'][logpos].rstrip())
logpos += 1
t.join()
if 'log' not in job:
Expand Down Expand Up @@ -337,15 +338,19 @@ def provision(opts): # noqa
value = value_from_resource(value, adminUser)
logger.info('Setting %s to %r', key, value)
Setting().set(key, value)
images = []
if getattr(opts, 'slicer-cli-image-pull', None):
images = list(dict.fromkeys(getattr(opts, 'slicer-cli-image-pull', None)))
try:
get_slicer_images(getattr(opts, 'slicer-cli-image-pull', None),
adminUser, alwaysPull=True)
except Exception:
logger.info('Cannot fetch slicer-cli-images.')
if getattr(opts, 'slicer-cli-image', None):
images = [image for image in dict.fromkeys(getattr(opts, 'slicer-cli-image', None))
if image not in images]
try:
get_slicer_images(getattr(opts, 'slicer-cli-image', None), adminUser)
get_slicer_images(images, adminUser)
except Exception:
logger.info('Cannot fetch slicer-cli-images.')

Expand Down
11 changes: 9 additions & 2 deletions devops/minimal/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def get_slicer_images(imageList, adminUser, alwaysPull=False):
job = Job().load(id=job['_id'], user=adminUser, includeLog=True)
if 'log' in job:
while logpos < len(job['log']):
logger.info(job['log'][logpos].rstrip())
if 'Pulling' not in job['log'][logpos] or '%' not in job['log'][logpos]:
logger.info(job['log'][logpos].rstrip())
logpos += 1
t.join()
if 'log' not in job:
Expand Down Expand Up @@ -337,15 +338,19 @@ def provision(opts): # noqa
value = value_from_resource(value, adminUser)
logger.info('Setting %s to %r', key, value)
Setting().set(key, value)
images = []
if getattr(opts, 'slicer-cli-image-pull', None):
images = list(dict.fromkeys(getattr(opts, 'slicer-cli-image-pull', None)))
try:
get_slicer_images(getattr(opts, 'slicer-cli-image-pull', None),
adminUser, alwaysPull=True)
except Exception:
logger.info('Cannot fetch slicer-cli-images.')
if getattr(opts, 'slicer-cli-image', None):
images = [image for image in dict.fromkeys(getattr(opts, 'slicer-cli-image', None))
if image not in images]
try:
get_slicer_images(getattr(opts, 'slicer-cli-image', None), adminUser)
get_slicer_images(images, adminUser)
except Exception:
logger.info('Cannot fetch slicer-cli-images.')

Expand Down Expand Up @@ -700,8 +705,10 @@ def __call__(self, parser, namespace, values, option_string=None):
if getattr(opts, 'portion', None) in {'main', None}:
# This loads plugins, allowing setting validation. We want the import
# to be after the preprovision step.
from girder import _attachFileLogHandlers
from girder.utility.server import configureServer

_attachFileLogHandlers()
configureServer()
if getattr(opts, 'mongo-compat', None) is not False:
from girder.models import getDbConnection
Expand Down

0 comments on commit 5e59ecb

Please sign in to comment.