Skip to content

Commit 3bdba8c

Browse files
authored
Add option to specify image tag when submitting batch tasks (#1330)
- overrides default image tag, which is set in batch configuration - allows user to run tasks on an older image (e.g. with python 3.8 support)
1 parent 9c3c39b commit 3bdba8c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/tlo/cli.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ def scenario_run(scenario_file, draw_only, draw: tuple, output_dir=None):
8888
@click.option("--asserts-on", type=bool, default=False, is_flag=True, help="Enable assertions in simulation run.")
8989
@click.option("--more-memory", type=bool, default=False, is_flag=True,
9090
help="Request machine wth more memory (for larger population sizes).")
91+
@click.option("--image-tag", type=str, help="Tag of the Docker image to use.")
9192
@click.option("--keep-pool-alive", type=bool, default=False, is_flag=True, hidden=True)
9293
@click.pass_context
93-
def batch_submit(ctx, scenario_file, asserts_on, more_memory, keep_pool_alive):
94+
def batch_submit(ctx, scenario_file, asserts_on, more_memory, keep_pool_alive, image_tag=None):
9495
"""Submit a scenario to the batch system.
9596
9697
SCENARIO_FILE is path to file containing scenario class.
@@ -180,8 +181,14 @@ def batch_submit(ctx, scenario_file, asserts_on, more_memory, keep_pool_alive):
180181
password=config["REGISTRY"]["KEY"],
181182
)
182183

183-
# Name of the image in the registry
184-
image_name = config["REGISTRY"]["SERVER"] + "/" + config["REGISTRY"]["IMAGE_NAME"]
184+
# url of the docker image to run the tasks
185+
image_name = f"{config['REGISTRY']['SERVER']}/{config['REGISTRY']['IMAGE']}"
186+
187+
# use the supplied image tag if provided, otherwise use the default
188+
if image_tag is None:
189+
image_name = f"{image_name}:{config['REGISTRY']['DEFAULT_TAG']}"
190+
else:
191+
image_name = f"{image_name}:{image_tag}"
185192

186193
# Create container configuration, prefetching Docker images from the container registry
187194
container_conf = batch_models.ContainerConfiguration(

0 commit comments

Comments
 (0)