Skip to content

Commit c2bb2f4

Browse files
authored
Add samples and README for each CRD (#33)
1 parent 353dbee commit c2bb2f4

25 files changed

+1052
-0
lines changed

samples/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Job Sample Overview
2+
3+
This sample demonstrates how to start jobs using your own script, packaged in a SageMaker-compatible container, using the Amazon AWS Controllers for Kubernetes (ACK) service controller for Amazon SageMaker.
4+
5+
## Prerequisites
6+
7+
This sample assumes that you have already configured an Kubernetes cluster with the ACK operator. It also assumes that you have installed `kubectl` - you can find a link on our [installation page](To do).
8+
9+
You will also need an IAM role which has permissions to access your S3 resources and SageMaker. If you have not yet created a role with these permissions, you can find an example policy at [Amazon SageMaker Roles](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html#sagemaker-roles-createtrainingjob-perms).
10+
11+
### Creating your first Job
12+
13+
The easiest way to start is taking a look at the sample training jobs and its corresponding [README](/samples/training/README.md)

samples/batch_transform/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Batch Transform Job Sample
2+
3+
This sample demonstrates how to start batch transform jobs using your own batch-transform script, packaged in a SageMaker-compatible container, using the Amazon AWS Controllers for Kubernetes (ACK) service controller for Amazon SageMaker.
4+
5+
## Prerequisites
6+
7+
This sample assumes that you have already configured an Kubernetes cluster with the ACK operator. It also assumes that you have installed `kubectl` - you can find a link on our [installation page](To do).
8+
9+
You will also need a model in SageMaker for this sample. If you do not have one you must first create a [model](/samples/model/README.md).
10+
11+
### Updating the Batch Transform Job Specification
12+
13+
In the `my-batch-transform-job.yaml` file, modify the placeholder values with those associated with your account and batchtransform job.
14+
15+
## Submitting your Batch Transform Job
16+
17+
### Create a Batch Transform Job
18+
19+
To submit your prepared batch transform job specification, apply the specification to your Kubernetes cluster as such:
20+
```
21+
$ kubectl apply -f my-batch-transform-job.yaml
22+
batch-transformjob.sagemaker.services.k8s.aws.amazon.com/my-batch-transform-job created
23+
```
24+
25+
### List Batch Transform Jobs
26+
27+
To list all Batch Transform Jobs created using the ACK controller use the following command:
28+
```
29+
$ kubectl get batch-transformjob
30+
```
31+
32+
### Describe a Batch Transform Job
33+
34+
To get more details about the Batch Transform Job once it's submitted, like checking the status, errors or parameters of the Batch Transform Job use the following command:
35+
```
36+
$ kubectl describe batch-transformjob my-batch-transform-job
37+
```
38+
39+
### Delete a Batch Transform Job
40+
To delete the Batch Transform Job, use the following command:
41+
```
42+
$ kubectl delete batch-transformjob my-batch-transform-job
43+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: sagemaker.services.k8s.aws/v1alpha1
2+
kind: TransformJob
3+
metadata:
4+
name: <YOUR JOB NAME>
5+
spec:
6+
# Name that will appear in SageMaker console
7+
transformJobName: <YOUR JOB NAME>
8+
# Name of your model in SageMaker
9+
modelName: <YOUR MODEL NAME>
10+
transformInput:
11+
contentType: text/csv
12+
dataSource:
13+
s3DataSource:
14+
s3DataType: S3Prefix
15+
# The source of the transform data
16+
s3URI: s3://<YOUR BUCKET/PATH>
17+
transformOutput:
18+
# The output path of our transform
19+
s3OutputPath: s3://<YOUR BUCKET/OUTPUT>
20+
transformResources:
21+
instanceCount: 1
22+
instanceType: ml.m4.xlarge

samples/endpoint/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Endpoint Sample
2+
3+
This sample demonstrates how to create Endpoints using your own Endpoint_base/config script, packaged in a SageMaker-compatible container, using the Amazon AWS Controllers for Kubernetes (ACK) service controller for Amazon SageMaker.
4+
5+
## Prerequisites
6+
7+
This sample assumes that you have already configured an Kubernetes cluster with the ACK operator. It also assumes that you have installed `kubectl` - you can find a link on our [installation page](To do).
8+
9+
You will also need a model in SageMaker for this sample. If you do not have one you must first create a [model](/samples/model/README.md)
10+
11+
In order to run [endpoint_base](/samples/endpoint/endpoint_base.yaml) you will need an endpoint_config which can be created by [endpoint_config](/samples/endpoint/endpoint_config.yaml)
12+
13+
### Updating the Endpoint Specification
14+
15+
In the `endpoint_config.yaml` file, modify the placeholder values with those associated with your account. The `spec.productionVariants.ModelName` should be the SageMaker model from the previous step.
16+
17+
## Submitting your Endpoint Specification
18+
19+
### Create an Endpoint Config and Endpoint
20+
21+
To submit your prepared endpoint specification, apply the specification to your Kubernetes cluster as such:
22+
```
23+
$ kubectl apply -f my-endpoint.yaml
24+
endpoints.sagemaker.services.k8s.aws.amazon.com/my-endpoint created
25+
```
26+
If it is a endpoint config:
27+
```
28+
$ kubectl apply -f my-endpoint-config.yaml
29+
endpointsconfigs.sagemaker.services.k8s.aws /my-endpoint-config created
30+
```
31+
32+
### List Endpoint Configs and Endpoints
33+
34+
To list all Endpoints created using the ACK controller use the following command:
35+
```
36+
$ kubectl get endpoints.sagemaker.services.k8s.aws
37+
```
38+
If it is a endpoint config it is endpointsconfigs.sagemaker.services.k8s.aws
39+
```
40+
$ kubectl get endpointsconfigs.sagemaker.services.k8s.aws
41+
```
42+
43+
### Describe an Endpoint Config and Endpoint
44+
45+
To get more details about the Endpoint once it's submitted, like checking the status, errors or parameters of the Endpoint use the following command:
46+
```
47+
$ kubectl describe endpoints.sagemaker.services.k8s.aws my-endpoint
48+
```
49+
50+
If it is a endpoint config it is endpointsconfigs.sagemaker.services.k8s.aws
51+
```
52+
$ kubectl describe endpointsconfigs.sagemaker.services.k8s.aws my-endpoint-config
53+
```
54+
55+
### Delete an Endpoint Config and Endpoint
56+
57+
To delete the Endpoint, use the following command:
58+
```
59+
$ kubectl delete endpoints.sagemaker.services.k8s.aws my-endpoint
60+
```
61+
62+
If it is a endpoint config it is endpointsconfigs.sagemaker.services.k8s.aws
63+
```
64+
$ kubectl delete endpointsconfigs.sagemaker.services.k8s.aws my-endpoint-config
65+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: sagemaker.services.k8s.aws/v1alpha1
2+
kind: Endpoint
3+
metadata:
4+
name: <YOUR ENDPOINT NAME>
5+
spec:
6+
endpointName: <YOUR ENDPOINT NAME>
7+
# Must already exist in SageMaker
8+
endpointConfigName: <YOUR ENDPOINT CONFIG NAME>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: sagemaker.services.k8s.aws/v1alpha1
2+
kind: EndpointConfig
3+
metadata:
4+
name: <YOUR ENDPOINT CONFIG NAME>
5+
spec:
6+
endpointConfigName: <YOUR ENDPOINT CONFIG NAME>
7+
productionVariants:
8+
# Name of Model created in Sagemaker
9+
- modelName: <YOUR MODEL NAME>
10+
variantName: AllTraffic
11+
instanceType: ml.c5.large
12+
initialVariantWeight: 1
13+
initialInstanceCount: 1
14+
# OPTIONAL To enable this endpoint to capture data from bias/quality/explainability dataCapture is required
15+
dataCaptureConfig:
16+
enableCapture: true #
17+
destinationS3URI: s3://<YOUR BUCKET>/sagemaker/endpoint_config/datacapture
18+
initialSamplingPercentage: 100
19+
captureOptions:
20+
- captureMode: Input
21+
- captureMode: Output
22+
captureContentTypeHeader:
23+
csvContentTypes:
24+
- "text/csv"
25+
jsonContentTypes:
26+
- "application/json"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Hyperparameter Tuning Job Sample
2+
3+
This sample demonstrates how to start hyperparameter jobs using your own hyperparameter script, packaged in a SageMaker-compatible container, using the Amazon AWS Controllers for Kubernetes (ACK) service controller for Amazon SageMaker.
4+
5+
## Prerequisites
6+
7+
This sample assumes that you have already configured an Kubernetes cluster with the ACK operator. It also assumes that you have installed `kubectl` - you can find a link on our [installation page](To do).
8+
9+
In order to follow this script, you must first create a hyperparameter script packaged in a Dockerfile that is [compatible with Amazon SageMaker](https://docs.aws.amazon.com/sagemaker/latest/dg/amazon-sagemaker-containers.html). Here is a list of available [containers](https://github.com/aws/deep-learning-containers/blob/master/available_images.md)
10+
11+
### Get an Image
12+
13+
All SageMaker Hyperparameter jobs are run from within a container with all necessary dependencies and modules pre-installed and with the hyperparameter scripts referencing the acceptable input and output directories. Sample container images are [available](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html).
14+
15+
A container image URL and tag looks has the following structure:
16+
```
17+
<account number>.dkr.ecr.<region>.amazonaws.com/<image name>:<tag>
18+
```
19+
20+
### Updating the Hyperparameter Specification
21+
22+
In the `my-hyperparameter-job.yaml` file, modify the placeholder values with those associated with your account and hyperparameter job.
23+
24+
### Enabling Spot Training
25+
In the `my-hyperparameter-job.yaml` file under `spec.trainingJobDefinition` add `enableManagedSpotTraining` and set the value to true. You will also need to specify a `spec.trainingJobDefinition.stoppingCondition.maxRuntimeInSeconds` and `spec.trainingJobDefinition.stoppingCondition.maxWaittimeInSeconds`
26+
27+
## Submitting your Hyperparameter Job
28+
29+
### Create a Hyperparameter Job
30+
31+
To submit your prepared hyperparameter job specification, apply the specification to your Kubernetes cluster as such:
32+
```
33+
$ kubectl apply -f my-hyperparameter-job.yaml
34+
hyperparametertuningjob.sagemaker.services.k8s.aws.amazon.com/my-hyperparameter-job created
35+
```
36+
37+
### List Hyperparameter Jobs
38+
39+
To list all Hyperparameter jobs created using the ACK controller use the following command:
40+
```
41+
$ kubectl get hyperparametertuningjob
42+
```
43+
44+
### Describe a Hyperparameter Job
45+
46+
To get more details about the Hyperparameter job once it's submitted, like checking the status, errors or parameters of the Hyperparameter job use the following command:
47+
```
48+
$ kubectl describe hyperparametertuningjob my-hyperparameter-job
49+
```
50+
51+
### Delete a Hyperparameter Job
52+
53+
To delete the hyperparameter job, use the following command:
54+
```
55+
$ kubectl delete hyperparametertuningjob my-hyperparameter-job
56+
```
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
apiVersion: sagemaker.services.k8s.aws/v1alpha1
2+
kind: HyperParameterTuningJob
3+
metadata:
4+
name: <YOUR JOB NAME>
5+
spec:
6+
hyperParameterTuningJobName: <YOUR JOB NAME>
7+
hyperParameterTuningJobConfig:
8+
strategy: Bayesian
9+
# Modify this parameter to meet your own script's needs
10+
hyperParameterTuningJobObjective:
11+
# Modify these parameters to meet your own script's needs
12+
type_: Minimize
13+
metricName: validation:error
14+
resourceLimits:
15+
maxNumberOfTrainingJobs: 10
16+
maxParallelTrainingJobs: 5
17+
parameterRanges:
18+
integerParameterRanges:
19+
# Modify these parameters to meet your own script's needs
20+
- name : num_round
21+
minValue: '10'
22+
maxValue: '20'
23+
scalingType: Linear
24+
continuousParameterRanges: []
25+
categoricalParameterRanges: []
26+
trainingJobDefinition:
27+
staticHyperParameters:
28+
# Modify these parameters to meet your own script's needs
29+
base_score: '0.5'
30+
booster: gbtree
31+
csv_weights: '0'
32+
dsplit: row
33+
grow_policy: depthwise
34+
lambda_bias: '0.0'
35+
max_bin: '256'
36+
max_leaves: '0'
37+
normalize_type: tree
38+
objective: reg:linear
39+
one_drop: '0'
40+
prob_buffer_row: '1.0'
41+
process_type: default
42+
rate_drop: '0.0'
43+
refresh_leaf: '1'
44+
sample_type: uniform
45+
scale_pos_weight: '1.0'
46+
silent: '0'
47+
sketch_eps: '0.03'
48+
skip_drop: '0.0'
49+
tree_method: auto
50+
tweedie_variance_power: '1.5'
51+
updater: grow_colmaker,prune
52+
algorithmSpecification:
53+
# The URL and tag of your ECR container
54+
# If you are not on us-west-2 you can find an imageURI here https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html
55+
trainingImage: 433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:1
56+
trainingInputMode: File
57+
# A role with SageMaker and S3 access
58+
# example arn:aws:iam::1234567890:role/service-role/AmazonSageMaker-ExecutionRole
59+
roleARN: <YOUR SAGEMAKER ROLE ARN>
60+
inputDataConfig:
61+
- channelName: train
62+
dataSource:
63+
s3DataSource:
64+
s3DataType: S3Prefix
65+
# The source of the training data
66+
s3URI: s3://<YOUR BUCKET/PATH>
67+
s3DataDistributionType: FullyReplicated
68+
contentType: text/csv
69+
compressionType: None
70+
recordWrapperType: None
71+
inputMode: File
72+
- channelName: validation
73+
dataSource:
74+
s3DataSource:
75+
s3DataType: S3Prefix
76+
# The source of the validation data
77+
s3URI: s3://<YOUR BUCKET/PATH>
78+
s3DataDistributionType: FullyReplicated
79+
contentType: text/csv
80+
compressionType: None
81+
recordWrapperType: None
82+
inputMode: File
83+
outputDataConfig:
84+
# The output path of our model
85+
s3OutputPath: s3://<YOUR BUCKET/OUTPUT>
86+
resourceConfig:
87+
instanceType: ml.m4.xlarge
88+
instanceCount: 1
89+
volumeSizeInGB: 25
90+
enableNetworkIsolation: true
91+
enableInterContainerTrafficEncryption: false
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Data Quality Job Definition Sample
2+
3+
This sample demonstrates how to start data quality job definitions using your own data-quality-job-definitions script, packaged in a SageMaker-compatible container, using the Amazon AWS Controllers for Kubernetes (ACK) service controller for Amazon SageMaker.
4+
5+
## Prerequisites
6+
7+
This sample assumes that you have already configured an Kubernetes cluster with the ACK operator. It also assumes that you have installed `kubectl` - you can find a link on our [installation page](To do).
8+
9+
You will need an [Endpoint](/samples/endpoint/README.md) configured in SageMaker and you will need to run a baselining job to generate baseline statistics and constraints.
10+
11+
### Get an Image
12+
13+
All SageMaker data quality job definitions are run from within a container with all necessary dependencies and modules pre-installed and with the data-quality scripts referencing the acceptable input and output directories. Sample container images are [available](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html).
14+
15+
A container image URL and tag looks has the following structure:
16+
```
17+
<account number>.dkr.ecr.<region>.amazonaws.com/<image name>:<tag>
18+
```
19+
20+
### Updating the Data Quality Job Definition Specification
21+
22+
In the `my-data-quality-job-definition.yaml` file, modify the placeholder values with those associated with your account.
23+
24+
## Submitting your Data Quality Job Definition
25+
26+
### Create a Data Quality Job Definition
27+
28+
To submit your prepared data quality job definition specification, apply the specification to your Kubernetes cluster as such:
29+
```
30+
$ kubectl apply -f my-data-quality-job-definition.yaml
31+
dataqualityjobdefinitions.sagemaker.services.k8s.aws.amazon.com/my-data-quality-job-definition created
32+
```
33+
34+
### List Data Quality Job Definitions
35+
36+
To monitor the data quality job definition status, you can use the following command:
37+
```
38+
$ kubectl get dataqualityjobdefinitions
39+
```
40+
41+
### Describe a Data Quality Job Definition
42+
43+
To get more details about the Data Quality Job Definition once it's submitted, like checking the status, errors or parameters of the Data Quality Job Definition use the following command:
44+
```
45+
$ kubectl describe dataqualityjobdefinitions my-data-quality-job-definition
46+
```
47+
You can also check Status.ackResourceMetadata.Arn to verify the data quality job definition was created successfully.
48+
49+
### Delete a Data Quality Job Definition
50+
51+
To delete the data quality job definition, use the following command:
52+
```
53+
$ kubectl delete dataqualityjobdefinitions my-data-quality-job-definition
54+
```

0 commit comments

Comments
 (0)