[英]Graphviz running on SageMaker notebook instance but not SageMaker Studio
[英]Passing Parameters to Sagemaker Notebook Instance
我想将文件名从 labda function 传递给 sagemaker notebook 实例
I am using Sagemaker notebook to perform a preprocessing job when a file landed in the s3 bucket. As such, I wrote a lambda function triggered by an S3 event that start the notebook. The lambda code is like
` import boto3
import logging
def lambda_handler(event, context):
print("notebook starting .....")
client = boto3.client('sagemaker')
client.start_notebook_instance(NotebookInstanceName='preprocess-dataset')
print("notebook started .....")
return 0
`
I want to pass the name of the file to this notebook so the notebook read the content of the file. How can I do that?
您可以使用 boto3 客户端add_tags(..)方法创建标签,以将值从您的 lambda 传递到您的笔记本实例。
然后在您的启动脚本中,您可以从该标签中读取并设置一个包含标签中值的环境变量。 您可以修改以下AWS sagemaker 启动脚本示例中的脚本以设置您的环境变量。
您现在可以在笔记本或 python 文件中使用该环境变量,其中包含您需要的值(在您的情况下为文件名)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.