我下面的代码是用AWS Sagmake木星笔记本编写的。但我希望从AWS (或AWS步骤函数)运行它,以支持自动执行。
在Step函数中有一个CreateProcessingJob,在sagemaker API中有一个https://sagemaker.readthedocs.io/en/stable/api/training/processing.html?highlight=frameworkprocessor#sagemaker.processing.ProcessingJob,在boto3中有一个create_processing_job --这是我能找到的最接近的.
这是可能的吗?如果必须手动从笔记本中执行所有这些Sagemaker功能,那么创建这些功能有什么意义呢..?
import boto3
import sagemaker
from sagemaker import get_execution_role
from sagemaker.sklearn.processing import SKLearnProcessor
from sagemaker.processing import FrameworkProcessor
from sagemaker.processing import ProcessingOutput
region = boto3.session.Session().region_name
role = get_execution_role()
est_cls = sagemaker.sklearn.estimator.SKLearn
framework_version_str="0.23-1"
script_processor = FrameworkProcessor(
role=role,
instance_count=8,
instance_type="ml.r5.8xlarge",
volume_size_in_gb=120,
max_runtime_in_seconds=432000,
estimator_cls=est_cls,
framework_version=framework_version_str
)
output_folder = 's3://bucket/out'
script_processor.run(
code="preprocessing.py",
source_dir = "code",
outputs=[
ProcessingOutput(output_name='preprocessed_data', source="/opt/ml/processing/train"),
],
arguments=["--bucket", "bucket", "--subfolder", "Training_data/"],
)
script_processor_job_description = script_processor.jobs[-1].describe()
print(script_processor_job_description)发布于 2022-02-07 05:44:05
您的代码似乎是为了在Sagemaker中触发数据预处理而编写的,这可以通过调用方法从Lambda中处理。其次,SageMaker为管理机器学习工作流的各个方面提供了一个健壮的工具集,像这样的预处理活动并不局限于从木星笔记本中手动运行。如果您的目标是自动化,我建议您签出SageMaker管道,以便在机器学习过程的每一个步骤中编排和自动化工作流。
发布于 2022-06-16 09:09:54
我不知道你的最终目标是什么,所以我列出了我的两个答案
选项1:只需在博客下面运行Sagemaker笔记本就提供了一种实现https://medium.com/analytics-vidhya/a-guide-to-schedule-sagemaker-notebooks-a7a09eb641f6的方法
选项2:创建和编排Sagemaker管道您需要在sagemaker中创建工作流管道,例如运行一次,以后的管道可以使用AWS事件桥触发。
https://github.com/aws-samples/scheduling-sagemaker-processing-with-sagemaker-pipelines
https://stackoverflow.com/questions/71009191
复制相似问题