Skip to content

Commit

Permalink
Specify vcpu and memory as resourceRequirements in AWS Batch executor (
Browse files Browse the repository at this point in the history
  • Loading branch information
aotimme authored Jun 6, 2024
1 parent 367033e commit fd9479d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
15 changes: 13 additions & 2 deletions redun/executors/aws_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,20 @@ def apply_resources(container_properties: Dict) -> None:
# Switch units, redun configs are in GB but AWS uses MB.
memory_mb = int(memory * 1024)

container_properties.update({"vcpus": vcpus, "memory": memory_mb})
container_properties["resourceRequirements"] = [
{
"type": "VCPU",
"value": str(vcpus),
},
{
"type": "MEMORY",
"value": str(memory_mb),
},
]
if gpus > 0:
container_properties["resourceRequirements"] = [{"type": "GPU", "value": str(gpus)}]
container_properties["resourceRequirements"].append(
{"type": "GPU", "value": str(gpus)}
)

if "containerOverrides" in batch_job_args:
apply_resources(batch_job_args["containerOverrides"])
Expand Down
24 changes: 15 additions & 9 deletions redun/tests/test_aws_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,11 @@ def test_job_submit_resources(get_or_create_job_definition_mock, get_aws_client_
retryStrategy={"attempts": 1},
containerOverrides={
"command": ["test_command"],
"vcpus": 4,
"memory": 8192,
"resourceRequirements": [{"type": "GPU", "value": "2"}],
"resourceRequirements": [
{"type": "VCPU", "value": "4"},
{"type": "MEMORY", "value": "8192"},
{"type": "GPU", "value": "2"},
],
},
propagateTags=True,
user="user-test",
Expand Down Expand Up @@ -529,18 +531,22 @@ def test_job_submit_resources(get_or_create_job_definition_mock, get_aws_client_
"targetNodes": "0",
"containerOverrides": {
"command": ["command_rank_0"],
"vcpus": 4,
"memory": 8192,
"resourceRequirements": [{"type": "GPU", "value": "2"}],
"resourceRequirements": [
{"type": "VCPU", "value": "4"},
{"type": "MEMORY", "value": "8192"},
{"type": "GPU", "value": "2"},
],
},
},
{
"targetNodes": "1:",
"containerOverrides": {
"command": ["command_rank_1"],
"vcpus": 4,
"memory": 8192,
"resourceRequirements": [{"type": "GPU", "value": "2"}],
"resourceRequirements": [
{"type": "VCPU", "value": "4"},
{"type": "MEMORY", "value": "8192"},
{"type": "GPU", "value": "2"},
],
},
},
]
Expand Down

0 comments on commit fd9479d

Please sign in to comment.