-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update make batch job task to be more generalizable
- Loading branch information
1 parent
c2dc817
commit 23d095a
Showing
1 changed file
with
19 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |