Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 30cefc6

Browse files
committedJan 27, 2025·
chore: adding inference runbook documentation
1 parent 08caac2 commit 30cefc6

File tree

9 files changed

+2513
-864
lines changed

9 files changed

+2513
-864
lines changed
 

‎conda/sm_notebook_env.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
channels:
2+
- conda-forge
3+
- defaults
4+
dependencies:
5+
- python=3.10.15
6+
- boto3=1.28.57
7+
- s3fs=2024.10.0
8+
- pandas=1.5.3
9+
- geopandas=1.0.1
10+
- pyogrio=0.10.0
11+
- rasterio
12+
- matplotlib=3.9.2
13+
- yaml=0.2.5
14+
- numpy=1.26.4
15+
- fiona=1.10.1
16+
- shapely=2.0.6
17+
- jsonschema=4.23.0
18+
- requests=2.32.3
19+
- sagemaker=2.232.3
20+
- pytest=7.3.1
21+
- pip=24.3.1
22+
- nodejs=20.17.0
23+
- git=2.40.1
24+
- pip:
25+
- earthpy=0.9.4
26+
- awscli==1.36.13
27+
name: osml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Description: "IAM role for OSML deployment and operation via SageMaker."
3+
4+
Resources:
5+
OSMLOpsRole:
6+
Type: "AWS::IAM::Role"
7+
Properties:
8+
AssumeRolePolicyDocument:
9+
Version: "2012-10-17"
10+
Statement:
11+
- Effect: "Allow"
12+
Principal:
13+
Service:
14+
- "sagemaker.amazonaws.com"
15+
Action:
16+
- "sts:AssumeRole"
17+
Description: "Role for OSML workflows on SageMaker."
18+
ManagedPolicyArns:
19+
- "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess"
20+
- "arn:aws:iam::aws:policy/AmazonSageMakerFullAccess"
21+
- "arn:aws:iam::aws:policy/AmazonS3FullAccess"
22+
- "arn:aws:iam::aws:policy/IAMFullAccess"
23+
- "arn:aws:iam::aws:policy/CloudWatchFullAccess"
24+
Policies:
25+
- PolicyName: "AdditionalPermissions"
26+
PolicyDocument:
27+
Version: "2012-10-17"
28+
Statement:
29+
- Effect: "Allow"
30+
Action:
31+
- "sqs:*"
32+
- "sns:*"
33+
- "iam:Get*"
34+
- "iam:List*"
35+
- "iam:PassRole"
36+
- "iam:SimulatePrincipalPolicy"
37+
- "kms:*"
38+
- "ssm:GetParameter"
39+
- "ssm:DescribeParameters"
40+
- "elasticloadbalancing:*"
41+
- "autoscaling:*"
42+
- "cloudformation:*"
43+
- "route53:*"
44+
Resource: "*"
45+
46+
Outputs:
47+
RoleArn:
48+
Description: "ARN of the provisioned IAM role for OSML workflows."
49+
Value: !GetAtt OSMLOpsRole.Arn

‎documentation/deployment/README.md

+161-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,149 @@
1-
# Guide to Configuring Your Deployment
1+
# Guide to Deploying OSML
22

3+
This guide provides step-by-step instructions to:
4+
1. Provision the required IAM role using the provided CloudFormation template.
5+
2. Provision a SageMaker Notebook Instance with the created Role.
6+
3. Bootstrap the notebook instance with required dependencies.
7+
4. Configure and deploy OSML into your account.
8+
9+
---
10+
11+
## 1: Provision the SageMaker Role
12+
13+
### Option 1: Using the AWS Management Console
14+
1. **Upload the CloudFormation Template**:
15+
- Navigate to the AWS Management Console.
16+
- Go to **CloudFormation** (Search for "CloudFormation" in the AWS Services search bar).
17+
18+
2. **Create a New Stack**:
19+
- Click **Create stack** and select **Upload a template file**.
20+
- Upload the `OSMLOpsRole-template.yaml` file.
21+
- Click **Next**.
22+
23+
3. **Configure Stack Details**:
24+
- **Stack Name**: Enter a unique name for the stack (e.g., `OSMLOpsRoleStack`).
25+
- **Parameters**: No additional parameters are required for this template.
26+
27+
4. **Review and Create**:
28+
- Review the stack configuration.
29+
- Acknowledge the capabilities to create IAM resources.
30+
- Click **Create stack**.
31+
32+
5. **Wait for the Stack to Complete**:
33+
- Wait for the stack status to change to `CREATE_COMPLETE`.
34+
- Note the **RoleArn** from the stack’s outputs. This will be the ARN of the provisioned role.
35+
36+
---
37+
38+
### Option 2: Using the AWS CLI
39+
40+
1. **Ensure AWS CLI is Installed and Configured**:
41+
- Install the AWS CLI if it's not already installed ([Installation Guide](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html)).
42+
- Verify your credentials and default region are configured:
43+
```bash
44+
aws configure
45+
```
46+
47+
2. **Validate the CloudFormation Template**:
48+
- Before creating the stack, validate the template to ensure there are no syntax errors:
49+
```bash
50+
aws cloudformation validate-template --template-body file://OSMLOpsRole-template.yaml
51+
```
52+
53+
3. **Create the CloudFormation Stack**:
54+
- Run the following command to create the stack:
55+
```bash
56+
aws cloudformation create-stack \
57+
--stack-name OSMLOpsRoleStack \
58+
--template-body file://OSMLOpsRole-template.yaml \
59+
--capabilities CAPABILITY_NAMED_IAM
60+
```
61+
62+
4. **Monitor the Stack Creation**:
63+
- Use the following command to track the stack's status:
64+
```bash
65+
aws cloudformation describe-stacks --stack-name OSMLOpsRoleStack
66+
```
67+
68+
5. **Retrieve the Role ARN**:
69+
- Once the stack status is `CREATE_COMPLETE`, retrieve the role ARN with:
70+
```bash
71+
aws cloudformation describe-stacks \
72+
--stack-name OSMLOpsRoleStack \
73+
--query "Stacks[0].Outputs[?OutputKey=='RoleArn'].OutputValue" \
74+
--output text
75+
```
76+
77+
---
78+
79+
### Notes
80+
- Both methods achieve the same outcome. Use the AWS CLI for automation or scripting and the AWS Management Console for a more guided experience.
81+
- Ensure you have sufficient IAM permissions to create resources via CloudFormation (e.g., `iam:CreateRole`, `cloudformation:CreateStack`).
82+
- For additional details on AWS CLI commands, refer to the [AWS CLI Command Reference](https://docs.aws.amazon.com/cli/latest/reference/).
83+
84+
---
85+
86+
## 2: Provision the SageMaker Notebook Instance
87+
88+
### Steps
89+
90+
1. **Log in to the AWS Management Console**:
91+
- Navigate to [AWS SageMaker](https://console.aws.amazon.com/sagemaker/).
92+
93+
2. **Open the Notebook Instances Page**:
94+
- From the SageMaker dashboard, select **Notebook instances** in the left-hand menu.
95+
96+
3. **Create a New Notebook Instance**:
97+
- Click the **Create notebook instance** button at the top of the page.
98+
99+
4. **Configure the Notebook Instance**:
100+
- **Notebook instance name**: Enter a unique name (e.g., `osml-notebook`).
101+
- **Instance type**: Choose an instance type based on your workload (e.g., `ml.t3.medium` for lightweight tasks or `ml.p3.2xlarge` for GPU-based tasks).
102+
- **IAM role**:
103+
- Select the role provisioned using the CloudFormation stack (e.g., `OSMLOpsRole`).
104+
- **Volume size**: Set the storage size (default: 5 GB or more, based on your requirements).
105+
106+
5. **Review and Create**:
107+
- Click **Create notebook instance**.
108+
- Wait for the instance status to transition to **InService**.
109+
110+
---
111+
112+
## 3: Bootstrap the Notebook Instance
113+
114+
### Steps
115+
116+
1. **Clone the Repository**:
117+
- Open a terminal in the SageMaker Notebook instance and clone the repository containing the bootstrap script:
118+
```bash
119+
git clone https://github.com/your-org/guidance-for-processing-overhead-imagery-on-aws.git
120+
cd guidance-for-processing-overhead-imagery-on-aws
121+
```
122+
123+
2. **Run the Bootstrap Script**:
124+
- Execute the `sm_bootstrap_conda.sh` script to set up the environment:
125+
```bash
126+
npm run sm:boostrap
127+
```
128+
129+
3. **Verify the Setup**:
130+
- After the script finishes, verify the environment setup:
131+
```bash
132+
conda list
133+
git lfs --version
134+
cdk --version
135+
```
136+
137+
---
138+
139+
## 4. Configuring and Deploying OSML
3140
This guide will help you configure various components of your AWS CDK application using the `cdk.context.json` file.
4141
By following these steps, you can customize the settings for your deployment without making any code updates.
5142
We will use the VPC as a use case example and also demonstrate the Model Runner Dataplane deployment. For a full list
6143
of configuration parameters available for various OSML constructs please refer to the published documentation such as the
7144
[MRDataplaneConfig](https://aws-solutions-library-samples.github.io/osml-cdk-constructs/classes/MRDataplaneConfig.html).
8145
9-
## Define Configurations in `cdk.context.json`
146+
### Define Configurations in `cdk.context.json`
10147
11148
The `cdk.context.json` file allows you to specify configuration parameters for various components of your application.
12149
Below is an example configuration where we demonstrate renaming the model runner cluster, specifying a custom role to
@@ -40,7 +177,7 @@ import for the model runner ECS task role, specifying a VPC to import, and which
40177
}
41178
```
42179
43-
### Configuration Parameters
180+
#### Configuration Parameters
44181
45182
- `projectName`: The name of the project - this will be used to tag stack names.
46183
- `account`: AWS account configuration.
@@ -53,14 +190,14 @@ import for the model runner ECS task role, specifying a VPC to import, and which
53190
- `buildFromSource`: Whether to build the component from source.
54191
- `config`: Each component has a configuration class that be used to customize its CDK resources.
55192
56-
## Understanding the Configuration Parser
193+
### Understanding the Configuration Parser
57194
58195
The `ConfigParser` class reads the configuration from the `cdk.context.json` file and makes it available for use in
59196
your CDK stacks. Ensure your `config-parser.ts` includes the necessary structure to read these configurations.
60197
You do not need to implement this as a customer but a breakdown of how it works is provided her for your understanding;
61198
incase further customization is required.
62199
63-
### Example `config-parser.ts`
200+
#### Example `config-parser.ts`
64201
65202
```typescript
66203
import { App } from "aws-cdk-lib";
@@ -100,11 +237,11 @@ export class AppConfig {
100237
export const appConfig = new AppConfig(new App());
101238
```
102239
103-
## Using the Configuration in Your CDK Stacks
240+
### Using the Configuration in Your CDK Stacks
104241
105242
You can now use the `ConfigParser` to configure your VPC and other components based on the settings provided in the `cdk.context.json` file. Here is an example of how to use it in a CDK stack.
106243
107-
### Example VPC Stack
244+
#### Example VPC Stack
108245
109246
```typescript
110247
import { App, Stack, StackProps } from 'aws-cdk-lib';
@@ -127,11 +264,11 @@ export class MyVpcStack extends Stack {
127264
}
128265
```
129266
130-
## Custom Model Deployment Configuration Instructions
267+
### Custom Model Deployment Configuration Instructions
131268
132269
Follow the steps below to configure and deploy your custom model using the provided configuration classes and AWS CDK constructs.
133270
134-
### Update the `cdk.context.json` File
271+
#### Update the `cdk.context.json` File
135272
136273
Your `cdk.context.json` file contains the configuration details required for deploying your custom model.
137274
You need to update this file with your specific configuration values. When configuring your custom model deployment,
@@ -175,13 +312,13 @@ containers from source for more specialized needs. Below is an example of how to
175312
```
176313
177314
178-
## Enabling Authentication
315+
### Enabling Authentication
179316
180317
Currently, there are two services that supports authentication
181318
- Tile Sever
182319
- Data Catalog
183320
184-
### Prerequisites
321+
#### Prerequisites
185322
186323
Before enabling authentication, you will need the following:
187324
- OIDC Authentication Server
@@ -198,7 +335,7 @@ Before enabling authentication, you will need the following:
198335
}
199336
```
200337
201-
1. To validate:
338+
2. To validate:
202339
- Upon successful deployment, go to your AWS Account -> API-GW -> find `<service>Dataplane` (ie: `TSDataplane`) stack > `Outputs` tab, you will see an output similar to:
203340
```
204341
TSDataplaneTileServerRestApiRestApiTileServerRestApiEndpoint<id> | <url>
@@ -208,9 +345,20 @@ Before enabling authentication, you will need the following:
208345
```
209346
curl -X "GET" "<api endpoint>" -H "Authorization: Bearer $TOKEN"
210347
```
348+
---
211349
212350
## Summary
213351
214-
By following this guide, you can easily configure various components of your application using the `cdk.context.json` file. This approach centralizes your configuration, making it easier to manage and update settings for your application.
352+
By following this guide, you can easily configure various components of your application using the `cdk.context.json` file.
353+
This approach centralizes your configuration, making it easier to manage and update settings for your application.
215354
216355
For more details on the available configurations and options, refer to the documentation provided by the `osml-cdk-constructs` package.
356+
357+
## Notes
358+
- Remember to stop or delete the notebook instance when not in use to avoid unnecessary charges.
359+
360+
## Additional Resources
361+
362+
- [AWS CloudFormation Documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html)
363+
- [AWS SageMaker Documentation](https://docs.aws.amazon.com/sagemaker/latest/dg/gs-setup-working-env.html)
364+
- [Conda Documentation](https://docs.conda.io/projects/conda/en/latest/)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Inference Runbook
2+
3+
## Overview
4+
This notebook provides a step-by-step guide to configuring and submitting inference requests to OSML ModelRunner.
5+
Each step corresponds to a heading in the notebook for easier navigation. The 'kernel' for this notebook appears in
6+
upper right, should be 'conda_python3'. If it is not, please change the kernel via Kernel in file menu.
7+
8+
## Prerequisites
9+
- Instructions for creating the SM Notebook instance is available in the [deployment README](../../deployment/README.md).

0 commit comments

Comments
 (0)
Please sign in to comment.