在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:aws-samples/aws-research-workshops开源软件地址:https://github.com/aws-samples/aws-research-workshops开源编程语言:Jupyter Notebook 78.2%开源软件介绍:AWS Research WorkshopsThis repo provides a managed SageMaker jupyter notebook with a number of notebooks for hands on workshops in data lakes, AI/ML, Batch, IoT, and Genomics. QuickstartTo get the AWS Research Workshop Notebook up and running in your own AWS account, follow these steps (if you do not have an AWS account, please see How do I create and activate a new Amazon Web Services account?):
Workshops
PrerequisitesAWS AccountIn order to complete these workshops you'll need a valid, usable AWS Account with Admin permissions. The code and instructions in these workshops assume only one student is using a given AWS account at a time. If you try sharing an account with another student, you'll run into naming conflicts for certain resources. Use a personal account or create a new AWS account to ensure you have the neccessary access. This should not be an AWS account from the company you work for. If you are doing this workshop as part of an AWS sponsored event, you will receive credits to cover the costs. BrowserWe recommend you use the latest version of Chrome or Firefox to complete this workshop. Text EditorFor any workshop module that requires use of the AWS Command Line Interface (see above), you also will need a plain text editor for writing scripts. Any editor that inserts Windows or other special characters potentially will cause scripts to fail. IAM Role for Notebook InstanceA new IAM Role will be required for the workshops. The Notebook Instance requires Python script instructions for creating the IAM Role (expand for details)
import logging
import os
import time
import argparse
import botocore.session
import botocore.exceptions
def create_role(iam, policy_name, assume_role_policy_document, inline_policy_name=None, policy_str=None):
"""Creates a new role if there is not already a role by that name"""
if role_exists(iam, policy_name):
logging.info('Role "%s" already exists. Assuming correct values.', policy_name)
return get_role_arn(iam, policy_name)
else:
response = iam.create_role(RoleName=policy_name,
AssumeRolePolicyDocument=assume_role_policy_document)
if policy_str is not None:
iam.put_role_policy(RoleName=policy_name,
PolicyName=inline_policy_name, PolicyDocument=policy_str)
logging.info('response for creating role = "%s"', response)
return response['Role']['Arn']
def role_exists(iam, role_name):
"""Checks if the role exists already"""
try:
iam.get_role(RoleName=role_name)
except botocore.exceptions.ClientError:
return False
return True
def get_role_arn(iam, role_name):
"""Gets the ARN of role"""
response = iam.get_role(RoleName=role_name)
return response['Role']['Arn']
iam = boto3.client('iam')
role_doc = {
"Version": "2012-10-17",
"Statement": [
{"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": [
"sagemaker.amazonaws.com",
"glue.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}]
}
inline_policy = {
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"*",
"*"
],
"Resource": [
"*"
],
"Effect": "Allow"
}
]
}
role_arn = workshop.create_role(iam, firehose_role_name, json.dumps(role_doc), firehose_policy_name, json.dumps(inline_policy))
print(role_arn) Launching Research Notebook InstanceSageMaker provides hosted Jupyter notebooks that require no setup, so you can begin processing your training data sets immediately. With a few clicks in the SageMaker console, you can create a fully managed notebook instance, pre-loaded with useful libraries for machine learning. Step-by-step instructions (expand for details)
Accessing the Notebook Instance
License SummaryThis sample code is made available under a modified MIT license. See the LICENSE file. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论