Skip to content

Instantly share code, notes, and snippets.

@tsibley
Created November 7, 2019 01:49
Show Gist options
  • Save tsibley/fd0b878302f2f176cb51b47e8fa58b91 to your computer and use it in GitHub Desktop.
Save tsibley/fd0b878302f2f176cb51b47e8fa58b91 to your computer and use it in GitHub Desktop.
diff --git a/nextstrain/cli/runner/aws_batch/__init__.py b/nextstrain/cli/runner/aws_batch/__init__.py
index 6f85cbe..687d97a 100644
--- a/nextstrain/cli/runner/aws_batch/__init__.py
+++ b/nextstrain/cli/runner/aws_batch/__init__.py
@@ -14,6 +14,7 @@ from uuid import uuid4
from ...types import RunnerTestResults, Tuple
from ...util import colored, resolve_path, warn
from ... import config
+from .. import docker
from . import jobs, logs, s3
@@ -43,6 +44,13 @@ def register_arguments(parser) -> None:
"development options for --aws-batch",
"See <https://github.com/nextstrain/cli/tree/master/doc/aws-batch.md>\nfor more information.")
+ # XXX TODO: Support --image like runner.docker does. Ideally the two
+ # runners could both use --image, but it may be necessary to prefix the
+ # option here with --aws-batch-image.
+ #
+ # The default for this option should be `docker.DEFAULT_IMAGE`, as imported
+ # from the nextstrain.cli.runner.docker module.
+
development.add_argument(
"--aws-batch-job",
dest = "job_definition",
@@ -123,6 +131,7 @@ def run(opts, argv, working_volume = None, extra_env = {}) -> int:
try:
job = jobs.submit(
name = run_id,
+ image = opts.image,
queue = opts.job_queue,
definition = opts.job_definition,
cpus = opts.cpus,
diff --git a/nextstrain/cli/runner/aws_batch/jobs.py b/nextstrain/cli/runner/aws_batch/jobs.py
index 9754b89..f3d2274 100644
--- a/nextstrain/cli/runner/aws_batch/jobs.py
+++ b/nextstrain/cli/runner/aws_batch/jobs.py
@@ -135,6 +135,7 @@ class JobState:
def submit(name: str,
+ image: str,
queue: str,
definition: str,
cpus: Optional[int],
@@ -149,6 +150,9 @@ def submit(name: str,
"""
batch = aws.client_with_default_region("batch")
+ # XXX TODO: create a new job definition for this image if necessary, based
+ # on the definition provided.
+
submission = batch.submit_job(
jobName = name,
jobQueue = queue,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment