Skip to content

Commit

Permalink
Add option to specify image tag when submitting batch tasks (#1330)
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
tamuri authored and joehcollins committed May 9, 2024
1 parent 932519a commit 4ef11d5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/tlo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ def scenario_run(scenario_file, draw_only, draw: tuple, output_dir=None):

@cli.command()
@click.argument("scenario_file", type=click.Path(exists=True))
@click.option("--asserts-on", type=bool, default=False, is_flag=True, help="Enable assertions in simulation run.")
@click.option("--more-memory", type=bool, default=False, is_flag=True,
help="Request machine wth more memory (for larger population sizes).")
@click.option("--image-tag", type=str, help="Tag of the Docker image to use.")
@click.option("--keep-pool-alive", type=bool, default=False, is_flag=True, hidden=True)
@click.pass_context
def batch_submit(ctx, scenario_file, keep_pool_alive):
def batch_submit(ctx, scenario_file, asserts_on, more_memory, keep_pool_alive, image_tag=None):
"""Submit a scenario to the batch system.
SCENARIO_FILE is path to file containing scenario class.
Expand Down Expand Up @@ -170,8 +174,14 @@ def batch_submit(ctx, scenario_file, keep_pool_alive):
password=config["REGISTRY"]["KEY"],
)

# Name of the image in the registry
image_name = config["REGISTRY"]["SERVER"] + "/" + config["REGISTRY"]["IMAGE_NAME"]
# url of the docker image to run the tasks
image_name = f"{config['REGISTRY']['SERVER']}/{config['REGISTRY']['IMAGE']}"

# use the supplied image tag if provided, otherwise use the default
if image_tag is None:
image_name = f"{image_name}:{config['REGISTRY']['DEFAULT_TAG']}"
else:
image_name = f"{image_name}:{image_tag}"

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

0 comments on commit 4ef11d5

Please sign in to comment.