本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 Apache Spark 运行处理作业
Apache Spark 是用于大规模数据处理的统一分析引擎。Amazon SageMaker AI 提供了预构建的 Docker 映像,包括 Apache Spark 和运行分布式数据处理作业所需的其他依赖项。下面举例说明如何使用 Apache Spark 运行 Amazon SageMaker Processing 作业。
通过 Amazon SageMaker Python SDK
包含 Spark 映像的源代码和 Dockerfile 的代码存储库可在 GitHub
您可以使用 sagemaker.spark.PySparkProcessorsagemaker.spark.SparkJarProcessor
以下代码示例演示了如何运行调用 PySpark 脚本 preprocess.py 的处理作业。
from sagemaker.spark.processing import PySparkProcessor spark_processor = PySparkProcessor( base_job_name="spark-preprocessor", framework_version="2.4", role=role, instance_count=2, instance_type="ml.m5.xlarge", max_runtime_in_seconds=1200, ) spark_processor.run( submit_app="preprocess.py", arguments=['s3_input_bucket', bucket, 's3_input_key_prefix', input_prefix, 's3_output_bucket', bucket, 's3_output_key_prefix', output_prefix] )
要深入研究,请参阅“使用 Apache Spark 和 SageMaker Processing 进行分布式数据处理”示例笔记本
如果您没有使用 Amazon SageMaker AI Python SDK
要了解有关结合使用 SageMaker Python SDK 和处理容器的更多信息,请参阅 Amazon SageMaker AI Python SDK