Skip to content

Commit 85dd43c

Browse files
committed
schedulers/aws_batch: add a scheduler to launch jobs directly on aws_batch
1 parent 4b989d5 commit 85dd43c

File tree

8 files changed

+764
-0
lines changed

8 files changed

+764
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: AWS Batch Integration Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
awsbatch:
11+
runs-on: ubuntu-18.04
12+
permissions:
13+
id-token: write
14+
contents: read
15+
steps:
16+
- name: Setup Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.9
20+
architecture: x64
21+
- name: Checkout TorchX
22+
uses: actions/checkout@v2
23+
- name: Configure AWS
24+
env:
25+
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
26+
run: |
27+
if [ -n "$AWS_ROLE_ARN" ]; then
28+
export AWS_WEB_IDENTITY_TOKEN_FILE=/tmp/awscreds
29+
export AWS_DEFAULT_REGION=us-west-2
30+
31+
echo AWS_WEB_IDENTITY_TOKEN_FILE=$AWS_WEB_IDENTITY_TOKEN_FILE >> $GITHUB_ENV
32+
echo AWS_ROLE_ARN=$AWS_ROLE_ARN >> $GITHUB_ENV
33+
echo AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION >> $GITHUB_ENV
34+
35+
curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r '.value' > $AWS_WEB_IDENTITY_TOKEN_FILE
36+
fi
37+
- name: Install dependencies
38+
run: |
39+
set -eux
40+
pip install -e .[dev]
41+
- name: Run AWS Batch Integration Tests
42+
run: |
43+
set -ex
44+
45+
scripts/awsbatchint.sh

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ ts==0.5.1
2121
usort==0.6.4
2222
ipython
2323
pytest
24+
boto3==1.20.49

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Works With
9797
schedulers/kubernetes
9898
schedulers/slurm
9999
schedulers/ray
100+
schedulers/aws_batch
100101

101102
.. _Pipelines:
102103
.. toctree::

docs/source/schedulers/aws_batch.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
AWS Batch
2+
=================
3+
4+
.. automodule:: torchx.schedulers.aws_batch_scheduler
5+
.. currentmodule:: torchx.schedulers.aws_batch_scheduler
6+
7+
.. autoclass:: AWSBatchScheduler
8+
:members:

scripts/awsbatchint.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
APP_ID="$(torchx run --wait --scheduler aws_batch -c queue=torchx utils.echo)"
11+
torchx status "$APP_ID"
12+
torchx describe "$APP_ID"
13+
torchx log "$APP_ID"
14+
LINES="$(torchx log "$APP_ID" | wc -l)"
15+
16+
if [ "$LINES" -ne 1 ]
17+
then
18+
echo "expected 1 log lines"
19+
exit 1
20+
fi

torchx/schedulers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from typing import Dict, Optional
99

10+
import torchx.schedulers.aws_batch_scheduler as aws_batch_scheduler
1011
import torchx.schedulers.docker_scheduler as docker_scheduler
1112
import torchx.schedulers.kubernetes_scheduler as kubernetes_scheduler
1213
import torchx.schedulers.local_scheduler as local_scheduler
@@ -48,6 +49,7 @@ def get_scheduler_factories() -> Dict[str, SchedulerFactory]:
4849
"local_cwd": local_scheduler.create_cwd_scheduler,
4950
"slurm": slurm_scheduler.create_scheduler,
5051
"kubernetes": kubernetes_scheduler.create_scheduler,
52+
"aws_batch": aws_batch_scheduler.create_scheduler,
5153
}
5254

5355
ray_scheduler_creator = try_get_ray_scheduler()

0 commit comments

Comments
 (0)