Skip to content

Commit

Permalink
Update make batch job task to be more generalizable
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicasyu committed Jun 23, 2023
1 parent c2dc817 commit 23d095a
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/container_collection/batch/make_batch_job.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
from typing import Optional


def make_batch_job(
name: str,
image: str,
account: str,
region: str,
user: str,
vcpus: int,
memory: int,
prefix: str,
environment: Optional[list[dict[str, str]]] = None,
job_role_arn: Optional[str] = None,
) -> dict:
container_properties = {
"image": image,
"vcpus": vcpus,
"memory": memory,
}

if environment is not None:
container_properties["environment"] = environment

if job_role_arn is not None:
container_properties["jobRoleArn"] = job_role_arn

return {
"jobDefinitionName": f"{user}_{name}",
"jobDefinitionName": name,
"type": "container",
"containerProperties": {
"image": f"{account}.dkr.ecr.{region}.amazonaws.com/{user}/{image}",
"vcpus": vcpus,
"memory": memory,
"environment": [
{"name": "SIMULATION_TYPE", "value": "AWS"},
{"name": "BATCH_WORKING_URL", "value": prefix},
{"name": "FILE_SET_NAME", "value": name},
],
"jobRoleArn": f"arn:aws:iam::{account}:role/BatchJobRole",
},
"containerProperties": container_properties,
}

0 comments on commit 23d095a

Please sign in to comment.