Skip to content

Commit 2a27bdd

Browse files
authored
Trigger pull explictly if needed (#184)
fixes #179 The pull option was set as the default that will cause to download the latest version when it is available, which is not desired as discussed in #179. In most cases, users want to keep on using the image they pulled in the first place. The new version of image download has better happened when explicitly triggered by setting pull. This commit first makes --no-pull the default of --pull/no-pull option. The pull logic tweaks a bit so that when the image does not exist, it will anyway trigger the pull. If the image exists, the --pull needs to be set to trigger the pull.
1 parent 3fa83bf commit 2a27bdd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

aiidalab_launch/__main__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,19 @@ async def _async_start(
336336
)
337337

338338
# Obtain image (either via pull or local).
339-
if pull:
340-
msg = (
341-
f"Downloading image '{instance.profile.image}', this may take a while..."
342-
if instance.image is None
343-
else f"Downloading latest version of '{instance.profile.image}'..."
344-
)
339+
if instance.image is None:
340+
# always pull if no image is available
341+
msg = f"Downloading image '{profile.image}', this may take a while..."
342+
with spinner(msg):
343+
instance.pull()
344+
elif pull:
345+
# pull if explicitly requested and pull latest version of image
346+
msg = f"Downloading latest version of '{profile.image}'..."
345347
with spinner(msg):
346348
instance.pull()
349+
else:
350+
# use local image
351+
msg = f"Using local image '{profile.image}'."
347352

348353
if instance.image is None:
349354
raise click.ClickException(
@@ -506,7 +511,7 @@ async def _async_start(
506511
)
507512
@click.option(
508513
"--pull/--no-pull",
509-
default=True,
514+
default=False,
510515
help=(
511516
"Specify whether to pull the configured image prior to the first start "
512517
"of the container."

0 commit comments

Comments
 (0)