Sm Training Queues Getting Started With Model Trainer
Getting Started with AWS Batch for SageMaker Training jobs
This notebook's CI test result for us-west-2 is as follows. CI test results in other regions can be found at the end of the notebook.
This sample notebook will demonstrate how to submit some simple 'hello world' jobs to an AWS Batch job queue using a ModelTrainer. You can run any of the cells in this notebook interactively to experiment with using your queue. Batch will take care of ensuring your jobs run automatically as your service environment capacity becomes available.
Setup and Configure Training Job Variables
We will need a single instance for a short duration for the sample jobs. Change any of the constant variables below to adjust the example to your liking.
Create Sample Resources
The diagram belows shows the Batch resources we'll create for this example.

You can use Batch Console to create these resources, or you can run the cell below. The create_resources function below will skip creating any resources that already exist.
Create Hello World Model Trainer
Now that our resources are created, we'll construct a simple ModelTrainer.
Create TrainingQueue object
Using our queue is as easy as referring to it by name in the TrainingQueue contructor. The TrainingQueue class within the SageMaker Python SDK provides built in support for working with Batch queues.
Submit Some Training Jobs
Submitting your job to the queue is done by calling queue.submit. This particular job doesn't require any data, but in general, data should be provided by specifying inputs.
Terminate a Job in the Queue
This next cell shows how to terminate an in queue job.
Monitor Job Status
This next cell shows how to list the jobs that have been submitted to the TrainingQueue. The TrainingQueue can list jobs by status, and each job can be described individually for more details. Once a TrainingQueuedJob has reached the STARTING status, the logs can be printed from underlying SageMaker training job.
Optional: Delete AWS Batch Resources
This shows how to delete the AWS Batch ServiceEnvironment and JobQueue. This step is completely optional, uncomment the code below to delete the resources created a few steps above.
Notebook CI Test Results
This notebook was tested in multiple regions. The test results are as follows, except for us-west-2 which is shown at the top of the notebook.